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

Fix false positive for RSpec/EmptyExampleGroup cop with iterator and simple conditional #2022

Merged

Conversation

lovro-bikic
Copy link
Contributor

@lovro-bikic lovro-bikic commented Jan 12, 2025

Fixes a false positive for RSpec/EmptyExampleGroup with iterator and simple conditional (one that doesn't have multiple statements, so it's not wrapped in a begin node).

Previously, code such as:

context 'foo' do
  [1, 2, 3].each do |x|
    if x.odd?
      it { expect(x).to be_odd }
    else
      it { expect(x).to be_even }
    end
  end
end

would register as an offense. With this patch, the offense isn't registered anymore.


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).

@lovro-bikic lovro-bikic requested a review from a team as a code owner January 12, 2025 22:08
Copy link
Member

@pirj pirj left a comment

Choose a reason for hiding this comment

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

Thank you

@pirj pirj requested a review from a team January 13, 2025 07:26
@lovro-bikic lovro-bikic force-pushed the fix/rspec-empty-example-group-false-positive branch from c45b1df to 774b40b Compare January 13, 2025 08:16
@lovro-bikic lovro-bikic force-pushed the fix/rspec-empty-example-group-false-positive branch from 774b40b to c43909d Compare January 15, 2025 13:12
Copy link
Member

@ydah ydah left a comment

Choose a reason for hiding this comment

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

Thank you!

@ydah ydah merged commit e8dd5ba into rubocop:master Jan 20, 2025
27 checks passed
@lovro-bikic lovro-bikic deleted the fix/rspec-empty-example-group-false-positive branch January 20, 2025 14:12
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.

3 participants