We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
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
I expect it to alter the code correctly.
In this case, it could be slice -- the following lines of code behave the same.
slice
This is semantically the same.
Also, the Rails/NegateInclude - if run prior - would possibly solve it.
test_rubocop.rb:3:18: C: [Correctable] Rails/NegateInclude: Use .exclude? and remove the negation part. address_array = ![:street_name, :house_number, :floor, :zipcode, :city, :country].include?(k) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
The Style/HashExcept cop dismisses the !
!
Create a file test_rubocop.rb and put the following lines in it:
test_rubocop.rb
➜ cat test_rubocop.rb address_hash_1 = base_data.reject { |k, _v| ![:street_name, :house_number, :floor, :zipcode, :city, :country].include?(k) } address_hash_2 = base_data.reject { |k, _v| [:street_name, :house_number, :floor, :zipcode, :city, :country].include?(k) }
Run: rubocop test_rubocop.rb --only Style/HashExcept and observe that it treats the lines as identical.
rubocop test_rubocop.rb --only Style/HashExcept
➜ rubocop test_rubocop.rb --only Style/HashExcept Inspecting 1 file C Offenses: test_rubocop.rb:1:26: C: [Correctable] Style/HashExcept: Use except(:street_name, :house_number, :floor, :zipcode, :city, :country) instead. address_hash_1 = base_data.reject { |k, _v| ![:street_name, :house_number, :floor, :zipcode, :city, :country].include?(k) } ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ test_rubocop.rb:2:28: C: [Correctable] Style/HashExcept: Use except(:street_name, :house_number, :floor, :zipcode, :city, :country) instead. address_hash_2 = base_data.reject { |k, _v| [:street_name, :house_number, :floor, :zipcode, :city, :country].include?(k) } ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 1 file inspected, 2 offenses detected, 2 offenses autocorrectable
➜ rubocop -V 1.64.1 (using Parser 3.3.3.0, rubocop-ast 1.31.3, running on ruby 3.2.4) [arm64-darwin23] - rubocop-capybara 2.21.0 - rubocop-factory_bot 2.26.1 - rubocop-minitest 0.35.0 - rubocop-performance 1.21.1 - rubocop-rails 2.25.0 - rubocop-rake 0.6.0
The text was updated successfully, but these errors were encountered:
Style/HashExcept
05f7738
Merge pull request #13015 from koic/fix_false_positives_for_style_has…
2d73bea
…h_except [Fix #13012] Fix false positives for `Style/HashExcept`
Successfully merging a pull request may close this issue.
Uh oh!
There was an error while loading. Please reload this page.
Expected behavior
I expect it to alter the code correctly.
In this case, it could be
slice
-- the following lines of code behave the same.This is semantically the same.
Also, the Rails/NegateInclude - if run prior - would possibly solve it.
Actual behavior
The Style/HashExcept cop dismisses the
!
Steps to reproduce the problem
Create a file
test_rubocop.rb
and put the following lines in it:Run:
rubocop test_rubocop.rb --only Style/HashExcept
and observe that it treats the lines as identical.RuboCop version
The text was updated successfully, but these errors were encountered: