-
-
Notifications
You must be signed in to change notification settings - Fork 81
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
Incorrect autocorrect for Performance/RedundantMatch
cop
#370
Comments
ymap
added a commit
to ymap/rubocop-performance
that referenced
this issue
Sep 14, 2023
…dantMatch` Fixes rubocop#370. This PR fixes an incorrect autocorrect for `Performance/RedundantMatch` when expressions with lower precedence than `=~` are used as an argument.
8 tasks
ymap
added a commit
to ymap/rubocop-performance
that referenced
this issue
Sep 15, 2023
…dantMatch` Fixes rubocop#370. This PR fixes an incorrect autocorrect for `Performance/RedundantMatch` when expressions with lower precedence than `=~` are used as an argument.
ymap
added a commit
to ymap/rubocop-performance
that referenced
this issue
Sep 15, 2023
…dantMatch` Fixes rubocop#370. This PR fixes an incorrect autocorrect for `Performance/RedundantMatch` when expressions with lower precedence than `=~` are used as an argument.
koic
added a commit
that referenced
this issue
Sep 15, 2023
…rformance_redundant_match [Fix #370] Fix an incorrect autocorrect for `Performance/RedundantMatch`
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I've noticed that the cop's autocorrection is incorrect when using operators with lower precedence than
=~
as an argument tomatch
.Here's the reproducible code:
Expected behavior
To preserve the original behavior, parentheses should be added around the RHS.
This code produces no output.
Actual behavior
Parentheses are missing, which results in the condition being evaluated as
(/regex/ =~ arg) || "default"
.This code outputs "pass".
Steps to reproduce the problem
example.rb
.bundle exec rubocop --only Performance/RedundantMatch -a example.rb
.RuboCop version
The text was updated successfully, but these errors were encountered: