-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Assignment of if
result incorrectly autocorrected
#2323
Comments
This is caused by the |
Unless self[:expression_id] has a value that should be overwritten with nil
|
Sorry, @swatosh, what do you mean? |
If self[:expression_id == 1234 before the method call, there is a code path Sorry, @swatosh https://github.com/swatosh, what do you mean? — |
Yes. That is the whole point of the linked PR. Currently, RuboCop removes the code path which sets |
Sorry, I missed the PR. I was responding to "...but the transform it does
|
@swatosh I think it meant that |
…recting in Style/IfUnlessModifier cop ...Otherwise, we could change the meaning of the "corrected" code.
I got this bad autocorrect. The original code:
Was changed to:
This of course is incompatible. It makes the whole assignment conditional.
If you think this has to be corrected at all then you should use ternary operator:
The text was updated successfully, but these errors were encountered: