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 a false positive for when method's receiver/argument is not the same as block key argument #11870

Merged
merged 1 commit into from
May 12, 2023

Conversation

fatkodima
Copy link
Contributor

Fixes #11868.

This PR properly checks method's receiver/argument, before considering if this is an offense.

Comment on lines 99 to 102
return false if (send_node.method?(:include?) || send_node.method?(:exclude?)) &&
send_node.first_argument&.source != key_arg.source

true
Copy link
Member

Choose a reason for hiding this comment

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

Can you tweak it?

Suggested change
return false if (send_node.method?(:include?) || send_node.method?(:exclude?)) &&
send_node.first_argument&.source != key_arg.source
true
return true if !send_node.method?(:include?) && !send_node.method?(:exclude?)
send_node.first_argument&.source != key_arg.source

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Tweaked.

@fatkodima fatkodima force-pushed the fix-hash_except-incorrect-arguments branch from 7850f9a to 1fdb7d6 Compare May 12, 2023 09:58
@koic koic merged commit 7ef8629 into rubocop:master May 12, 2023
28 checks passed
@koic
Copy link
Member

koic commented May 12, 2023

Thanks!

@fatkodima fatkodima deleted the fix-hash_except-incorrect-arguments branch May 12, 2023 14:45
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.

Incorrect substitution for Style/HashExcept
2 participants