-
-
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
Incorrect safe navigation autocorrection #5079
Comments
The safe navigation operator, introduced in ruby 2.3.0, evaluates the left hand side of That said, if |
The autocorrect also triggers when I have this code: Rubocop wants to rewrite it to: If
|
Right. Presumably the cop should not rewrite if the result is being used in a comparison, it should only rewrite if the truthiness of falsiness of the result is being used? |
I can not reproduce this using the code provided. Please add the complete output using |
Was able to reproduce it now. |
`Style/SafeNavigation` returns false positives and tries to autocorrect when safe guarding a comparison on a chained method call.
`Style/SafeNavigation` returns false positives and tries to autocorrect when safe guarding a comparison on a chained method call.
is automatically converted to
This is incorrect because state can be nil.
Expected behaviour: no changes required.
$ rubocop -V
Rubocop version: 0.51.0 (using Parser 2.4.0.2, running on ruby 2.4.1 x86_64-linux)
The text was updated successfully, but these errors were encountered: