Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use node pattern generic parameters to simplify a cop #930

Merged
merged 1 commit into from Jul 15, 2020

Conversation

pirj
Copy link
Member

@pirj pirj commented Jun 11, 2020

#804 (comment)

Support introduced in rubocop/rubocop-ast#31

Presumably generic parameters support will land in RuboCop 1.0 or 1.0.1 worst case.


Before submitting the PR make sure the following are checked:

  • Feature branch is up-to-date with master (if not - rebase it).
  • Squashed related commits together.
  • [-] Added tests.
  • [-] Updated documentation.
  • [-] Added an entry to the CHANGELOG.md if the new code introduces user-observable changes.
  • The build (bundle exec rake) passes (be sure to run this locally, since it may produce updated documentation that you will need to commit).

@pirj pirj self-assigned this Jun 11, 2020
rubocop-rspec.gemspec Outdated Show resolved Hide resolved
Gemfile Outdated Show resolved Hide resolved
@pirj pirj marked this pull request as ready for review July 15, 2020 09:18
@pirj
Copy link
Member Author

pirj commented Jul 15, 2020

RuboCop 0.8.7 we're currently depend on depends on rubocop-ast 0.1.0, and rubocop-ast has this feature baked-in. So this change is safe to merge without expecting breakages with earlier RuboCop versions.

@pirj pirj force-pushed the poc-generic-node-pattern-param-usage branch from c68c75c to 08b5f46 Compare July 15, 2020 09:23
@pirj pirj requested review from bquorning and Darhazer July 15, 2020 09:23
@pirj pirj changed the title POC usage of node pattern generic parameters Use node pattern generic parameters to simplify a cop Jul 15, 2020
end

def find_aggregate_failures(example_node)
example_node.send_node.each_ancestor(:block)
.find { |block_node| aggregate_failures_present?(block_node) }
.find { |block_node| aggregate_failures?(block_node, ANYTHING) }
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A new addition to rubocop-ast made it possible to pass in true and _-alike's.
That was it became possible to collapse two node matchers into one, since they only had that distinction.

One is used to match:

describe aggregate_examples: true do
# or
describe :aggregate_examples do

the other any of:

describe aggregate_examples: false do
# or
describe aggregate_examples: true do
# or
describe :aggregate_examples do

@pirj pirj force-pushed the poc-generic-node-pattern-param-usage branch from 08b5f46 to 1a47e9e Compare July 15, 2020 09:29
@pirj
Copy link
Member Author

pirj commented Jul 15, 2020

Green.

lib/rubocop/cop/rspec/multiple_expectations.rb Outdated Show resolved Hide resolved
@pirj pirj force-pushed the poc-generic-node-pattern-param-usage branch from 4afd467 to 4a6f646 Compare July 15, 2020 14:37
#804 (comment)
Support introduced in rubocop/rubocop-ast#31
Presumably this will land in RuboCop 1.0 or 1.0.1 worst case.
@pirj pirj force-pushed the poc-generic-node-pattern-param-usage branch from 4a6f646 to 3b41df3 Compare July 15, 2020 14:38
@bquorning bquorning merged commit 704ef22 into master Jul 15, 2020
@bquorning bquorning deleted the poc-generic-node-pattern-param-usage branch July 15, 2020 15:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants