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 an incorrect autocorrect for Style/MultipleComparison when statement with more comparisons precedes a statement with less comparisons #13087

Merged
merged 1 commit into from
Aug 2, 2024

Conversation

fatkodima
Copy link
Contributor

I caught an edge case for Style/MultipleComparison cop, when we have an expression with more comparisons that is followed by an expression with less comparisons.

x = 1
x == 1 || x == 2 || x == 3  # <=== more comparisons
x == 1 || x == 2            # <=== less comparisons

Is corrected to

x = 1
[1, 2, 3].include?(x)
[1, 2, 3, 1, 2, 3, 1, 2].include?(x)

But should be

x = 1
[1, 2, 3].include?(x)
[1, 2].include?(x)

…ement with more comparisons precedes a statement with less comparisons
@bbatsov bbatsov merged commit d821c4b into rubocop:master Aug 2, 2024
22 checks passed
@bbatsov
Copy link
Collaborator

bbatsov commented Aug 2, 2024

Nice catch!

@fatkodima fatkodima deleted the fix-multiple_comparison branch August 2, 2024 12:31
This pull request was closed.
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.

2 participants