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

Add Andrew to the hall of fame #928

Merged
merged 1 commit into from Jun 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Expand Up @@ -8,6 +8,7 @@
* Add new `SpecSuffixOnly` option to `RSpec/FilePath` cop. ([@zdennis][])
* Allow `RSpec/RepeatedExampleGroupBody` to differ only by described_class. ([@robotdana][])
* Fix `RSpec/FilePath` detection across sibling directories. ([@rolfschmidt][])
* Improve the performance of `RSpec/SubjectStub` by an order of magnitude. ([@andrykonchin][])

## 1.39.0 (2020-05-01)

Expand Down Expand Up @@ -514,3 +515,4 @@ Compatibility release so users can upgrade RuboCop to 0.51.0. No new features.
[@zdennis]: https://github.com/zdennis
[@robotdana]: https://github.com/robotdana
[@rolfschmidt]: https://github.com/rolfschmidt
[@andrykonchin]: https://github.com/andrykonchin
4 changes: 2 additions & 2 deletions lib/rubocop/cop/rspec/subject_stub.rb
Expand Up @@ -77,7 +77,7 @@ class SubjectStub < Cop

def on_block(node)
return unless example_group?(node)
return unless (processed_example_groups & node.ancestors).empty?
return if (processed_example_groups & node.ancestors).any?
Copy link
Collaborator

Choose a reason for hiding this comment

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

😁 ❤️


processed_example_groups << node
@explicit_subjects = find_all_explicit_subjects(node)
Expand All @@ -94,7 +94,7 @@ def processed_example_groups
end

def find_all_explicit_subjects(node)
node.each_descendant(:block).each_with_object({}) do |child, h|
node.each_descendant(:block).with_object({}) do |child, h|
Copy link
Collaborator

Choose a reason for hiding this comment

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

Today I learned about with_object. Hadn’t noticed that alias before. And it’s been there since 2.4‽

Copy link
Member Author

Choose a reason for hiding this comment

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

name = subject(child)
next unless name

Expand Down