Add DSL compiler for RuboCop def_node_matcher/def_node_search#2661
Draft
Vein05 wants to merge 1 commit into
Draft
Add DSL compiler for RuboCop def_node_matcher/def_node_search#2661Vein05 wants to merge 1 commit into
Vein05 wants to merge 1 commit into
Conversation
Initial skeleton for the RubocopNodePattern compiler that generates RBI files for RuboCop cops using def_node_matcher and def_node_search macros. Uses the param0 heuristic to detect macro-generated methods and source_location to extract patterns for capture counting. Resolves Shopify#2321
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a new
RubocopNodePatternDSL compiler that generates RBI files for RuboCop cops usingdef_node_matcheranddef_node_searchmacros.Detection Strategy
param0heuristic to identify macro-generated methods (no false positives across 594+ cops)[:opt, :param0]→def_node_matcher,[:req, :param0]→def_node_searchsource_locationto extract the pattern string and count capturesReturn Type Logic
def_node_matcher: 0 captures →T::Boolean, 1+ captures →T.untypeddef_node_search: predicate (?) →T::Boolean, otherwise →T::Enumerator[::RuboCop::AST::Node]%1,%2) as additionalT.untypedparametersStatus
🚧 Work in progress — initial skeleton with core functionality. Still TODO:
Resolves #2321
Test plan