-
-
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 Style/SafeNavigation transformation #7914
Comments
@adfoster-r7 Since rubocop is a You can disable the cop on that particular line: https://rubocop.readthedocs.io/en/latest/configuration/#disabling-cops-within-source-code - instead of disabling it entirely (like you did in linked PR). Question to maintainers is - should we mark this cop as |
The The code example is perfect for showing off the problem, but it is also a signal of a larger problem in the code itself. Narrowly looking at I will admit that |
We should absolutely mark this cop as unsafe (both as detecting false positives and as incorrect autocorrection) I just got burned by this when working on #7868. RuboCop's current API for I was refactoring the code to: lambda = autocorrect(node)
#...
lambda.call(node) if lambda I'll note that I see not good way to write this without disabling this cop in this case. |
Great rule, but definitely not safe to auto-correct. |
Thanks for the reminder @vlad-pisanov |
Given the following input file, after running rubocop it no longer works:
It currently gets corrected to the following, which breaks the code:
Expected behavior
Rubocop runs successfully on this file and produces valid Ruby
Actual behavior
After running Rubocop, and running the file:
Steps to reproduce the problem
Create a new file:
Confirm it works:
Run default rubocop:
Confirm that the file still works, in this case it doesn't:
RuboCop version
Version:
I have no custom
.rubocop.yml
file, so the default configuration appears to be:The text was updated successfully, but these errors were encountered: