-
-
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
False positive for Style/SafeNavigation
when safe guarding arithmetic operation or assignment
#5089
Comments
Same issue as #5079. The problem seems to be that the cop is not checking that the last method in a method chain is a "dot-less" method (comparisons, arithmetics, hash access, etc.) |
I'm working on a PR to fix it. |
tiagotex
added a commit
to tiagotex/rubocop
that referenced
this issue
Nov 22, 2017
Style/SafeNavigation returns false positives and tries to autocorrect when safeguarding a arithmetic operation or assignment on a chained method call.
11 tasks
I fixed the problems described in this issue, but not the problem referenced in #5079, I might take a stab at it later. |
bbatsov
pushed a commit
that referenced
this issue
Nov 22, 2017
Style/SafeNavigation returns false positives and tries to autocorrect when safeguarding a arithmetic operation or assignment on a chained method call.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Style/SafeNavigation
returns false positives and tries to autocorrect when safeguarding a arithmetic operation or assignment on a chained method call.Expected behavior
Rubocop shouldn't consider this an offense, since we don't want to do the operation when object is null.
Actual behavior
Rubocop removes the safe guard and uses the safe operator.
Steps to reproduce the problem
Rubocop tries to fix to:
RuboCop version
The text was updated successfully, but these errors were encountered: