Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix a false positive for
Style/SafeNavigation
This PR fixes the following error for `Style/SafeNavigation` when checking `foo&.empty?` in a conditional. ```console % cat example.rb do_something if ENV['VERSION'] && ENV['VERSION'].empty? % bunble exec rubocop -a example.rb --only Style/SafeNavigation,Lint/SafeNavigationWithEmpty (snip) Inspecting 1 file W Offenses: example.rb:1:17: W: [Corrected] Lint/SafeNavigationWithEmpty: Avoid calling empty? with the safe navigation operator in conditionals. do_something if ENV['VERSION']&.empty? ^^^^^^^^^^^^^^^^^^^^^^ example.rb:1:17: C: [Corrected] Style/SafeNavigation: Use safe navigation (&.) instead of checking if an object exists before calling the method. do_something if ENV['VERSION'] && ENV['VERSION'].empty? ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 0 files inspected, 2 offenses detected, 2 offenses corrected Infinite loop detected in /Users/koic/src/github.com/koic/rubocop-issues/rails/example.rb. /Users/koic/src/github.com/rubocop-hq/rubocop/lib/rubocop/runner.rb:289:in `check_for_infinite_loop' /Users/koic/src/github.com/rubocop-hq/rubocop/lib/rubocop/runner.rb:272:in `block in iterate_until_no_changes' /Users/koic/src/github.com/rubocop-hq/rubocop/lib/rubocop/runner.rb:271:in `loop' /Users/koic/src/github.com/rubocop-hq/rubocop/lib/rubocop/runner.rb:271:in `iterate_until_no_changes' /Users/koic/src/github.com/rubocop-hq/rubocop/lib/rubocop/runner.rb:242:in `do_inspection_loop' ``` I found it with the following code. https://github.com/rails/rails/blob/v6.0.3.2/activerecord/lib/active_record/railties/databases.rake#L120
- Loading branch information
Showing
5 changed files
with
32 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters