Feature request: DSL compiler for RuboCop's `def_node_matcher`
Open
Nobody has claimed this yet.
help-wanted
- Dominant language
- Ruby
- Stars
- 873
- Forks
- 164
- Avg merge
- 4d 27m
- Merged PRs (30d)
- 9
Description
This code:
class MyCop < ::RuboCop::Cop::Base
def_node_matcher :my_pattern?, <<~PATTERN
(send _ :some_method ...)
PATTERN
end
Should produce this RBI:
class MyCop < ::RuboCop::Cop::Base
sig do
params(
node: RuboCop::AST::Node,
block: T.proc.params(*captures: T.untyped).void,
).returns(T::Boolean)
end
def my_pattern?; end
end
Typing the block would be pretty challenging... we'd need to statically analyze the NodePattern, to figure out how many matches where will be. I just left it as an untyped varargs.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
No implementation file or test is named. Start by locating the def_node_matcher RBI-generation entry point and any existing NodePattern handling, then compare its output with the example; done means generating the shown method signature and untyped variadic block for the sample matcher.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ruby
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100