Add node pattern methods to handle dependency audits in a better way #3012
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.
brew tests
with your changes locally?#569 and #2662
RuboCop has pattern searching macros which simplify searching/matching nodes in AST.
Found documentation for same in the source of node_pattern.rb
This PR updates
depends_on
audits to use such pattern matching methods, so code becomes more readable and also fixes bug in previous code which wasn't detecting dependencies.(there is however one edge case where the value of a
depends_on
hash is an array, I know how exactly to implement that and will deal with that later)Edit: How did I derive those patterns? By running the below commands and looking at the AST.
$ ruby-parse -e 'depends_on :x11 => optional'
$ ruby-parse -e 'depends_on "readline" => :recommended'
cc @ilovezfs