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
Cop Lint/RedundantSafeNavigation with the autocorrect option fixes the code in a suboptimal way #11918
Comments
This is an unexpected false positive by |
There's also |
I'm seeing |
I also hit this with |
I'm seeing this as well with code that previously could return |
Since we need some of these methods to be able to return `nil` instead of `0` the rubocop rule preventing this usage with `to_i` has been disabled until: rubocop/rubocop#11918 is resolved.
Disable Lint/RedundantSafeNavigation until this is resolved: rubocop/rubocop#11918 Previously this code could return `nil` with the safe navigation and if this rubocop advice was followed `''` would be returned instead.
This is also the case for foo = something&.to_s || "hello"
# DOES NOT EQUAL...
foo = something.to_s || "hello" |
This cop also seems to flag this incorrectly: foo&.public_send(:bar) |
I think this can be closed since #8867 has been resolved? |
Sorry @bquorning I meant #11915 |
Actual behavior
I have the code:
I run rubocop with the autocorrect option:
I got the code:
and I run rubocop again:
Expected behavior
I expected to receive the following code:
RuboCop version
ydakuka@yauhenid:~/Work/project$ bin/rails_docker rubocop -V 1.52.0 (using Parser 3.2.2.1, rubocop-ast 1.28.1, running on ruby 2.7.8) [x86_64-linux] - rubocop-capybara 2.18.0 - rubocop-factory_bot 2.23.1 - rubocop-performance 1.17.1 - rubocop-rails 2.19.1 - rubocop-rake 0.6.0 - rubocop-rspec 2.22.0 - rubocop-thread_safety 0.5.1
The text was updated successfully, but these errors were encountered: