You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Lint/Ambiguous trips when self is part of the range. I don't see the ambiguity, but I might be wrong.
def foo
self..42
end
Parenthesis do not help, Lint/Ambiguous is still unhappy.
def foo
(self..42)
end
Parens around self makes Lint/Ambiguous happy, but I don't understand why. But now Style/RedundantParentheses is unhappy.
def foo
(self)..42
end
rubocop -A goes into an infinite loop between Lint/AmbiguousRange and Style/RedundantParentheses.
Expected behavior
Neither self..42 nor (self..42) seem ambiguous to me. I'd expect Lint/Ambiguous to accept either one. If it must be (self)..42 then Style/RedundantParentheses would be made to accept that.
Actual behavior
Infinite loop between Lint/AmbiguousRange and Style/RedundantParenthesis.
$ cat ~/.rubocop.yml
Lint/AmbiguousRange:
Enabled: true
$ rubocop --debug -A test.rb
For /Users/schwern/tmp: configuration from /Users/schwern/.rubocop.yml
Default configuration from /Users/schwern/.rvm/gems/ruby-2.7.4/gems/rubocop-1.21.0/config/default.yml
Inspecting 1 file
Scanning /Users/schwern/tmp/test.rb
W
Offenses:
test.rb:4:3: W: [Corrected] Lint/AmbiguousRange: Wrap complex range boundaries with parentheses to avoid ambiguity.
self..42
^^^^
test.rb:4:3: C: [Corrected] Style/RedundantParentheses: Don't use parentheses around a keyword.
(self)..42
^^^^^^
0 files inspected, 2 offenses detected, 2 offenses corrected
Infinite loop detected in /Users/schwern/tmp/test.rb and caused by Lint/AmbiguousRange -> Style/RedundantParentheses
/Users/schwern/.rvm/gems/ruby-2.7.4/gems/rubocop-1.21.0/lib/rubocop/runner.rb:298:in `check_for_infinite_loop'
/Users/schwern/.rvm/gems/ruby-2.7.4/gems/rubocop-1.21.0/lib/rubocop/runner.rb:281:in `block in iterate_until_no_changes'
/Users/schwern/.rvm/gems/ruby-2.7.4/gems/rubocop-1.21.0/lib/rubocop/runner.rb:280:in `loop'
/Users/schwern/.rvm/gems/ruby-2.7.4/gems/rubocop-1.21.0/lib/rubocop/runner.rb:280:in `iterate_until_no_changes'
/Users/schwern/.rvm/gems/ruby-2.7.4/gems/rubocop-1.21.0/lib/rubocop/runner.rb:249:in `do_inspection_loop'
/Users/schwern/.rvm/gems/ruby-2.7.4/gems/rubocop-1.21.0/lib/rubocop/runner.rb:130:in `block in file_offenses'
/Users/schwern/.rvm/gems/ruby-2.7.4/gems/rubocop-1.21.0/lib/rubocop/runner.rb:155:in `file_offense_cache'
/Users/schwern/.rvm/gems/ruby-2.7.4/gems/rubocop-1.21.0/lib/rubocop/runner.rb:129:in `file_offenses'
/Users/schwern/.rvm/gems/ruby-2.7.4/gems/rubocop-1.21.0/lib/rubocop/runner.rb:120:in `process_file'
/Users/schwern/.rvm/gems/ruby-2.7.4/gems/rubocop-1.21.0/lib/rubocop/runner.rb:101:in `block in each_inspected_file'
/Users/schwern/.rvm/gems/ruby-2.7.4/gems/rubocop-1.21.0/lib/rubocop/runner.rb:100:in `each'
/Users/schwern/.rvm/gems/ruby-2.7.4/gems/rubocop-1.21.0/lib/rubocop/runner.rb:100:in `reduce'
/Users/schwern/.rvm/gems/ruby-2.7.4/gems/rubocop-1.21.0/lib/rubocop/runner.rb:100:in `each_inspected_file'
/Users/schwern/.rvm/gems/ruby-2.7.4/gems/rubocop-1.21.0/lib/rubocop/runner.rb:86:in `inspect_files'
/Users/schwern/.rvm/gems/ruby-2.7.4/gems/rubocop-1.21.0/lib/rubocop/runner.rb:47:in `run'
/Users/schwern/.rvm/gems/ruby-2.7.4/gems/rubocop-1.21.0/lib/rubocop/cli/command/execute_runner.rb:26:in `block in execute_runner'
/Users/schwern/.rvm/gems/ruby-2.7.4/gems/rubocop-1.21.0/lib/rubocop/cli/command/execute_runner.rb:52:in `with_redirect'
/Users/schwern/.rvm/gems/ruby-2.7.4/gems/rubocop-1.21.0/lib/rubocop/cli/command/execute_runner.rb:25:in `execute_runner'
/Users/schwern/.rvm/gems/ruby-2.7.4/gems/rubocop-1.21.0/lib/rubocop/cli/command/execute_runner.rb:17:in `run'
/Users/schwern/.rvm/gems/ruby-2.7.4/gems/rubocop-1.21.0/lib/rubocop/cli/command.rb:11:in `run'
/Users/schwern/.rvm/gems/ruby-2.7.4/gems/rubocop-1.21.0/lib/rubocop/cli/environment.rb:18:in `run'
/Users/schwern/.rvm/gems/ruby-2.7.4/gems/rubocop-1.21.0/lib/rubocop/cli.rb:71:in `run_command'
/Users/schwern/.rvm/gems/ruby-2.7.4/gems/rubocop-1.21.0/lib/rubocop/cli.rb:78:in `execute_runners'
/Users/schwern/.rvm/gems/ruby-2.7.4/gems/rubocop-1.21.0/lib/rubocop/cli.rb:47:in `run'
/Users/schwern/.rvm/gems/ruby-2.7.4/gems/rubocop-1.21.0/exe/rubocop:12:in `block in <top (required)>'
/Users/schwern/.rvm/rubies/ruby-2.7.4/lib/ruby/2.7.0/benchmark.rb:308:in `realtime'
/Users/schwern/.rvm/gems/ruby-2.7.4/gems/rubocop-1.21.0/exe/rubocop:12:in `<top (required)>'
/Users/schwern/.rvm/gems/ruby-2.7.4/bin/rubocop:23:in `load'
/Users/schwern/.rvm/gems/ruby-2.7.4/bin/rubocop:23:in `<main>'
/Users/schwern/.rvm/gems/ruby-2.7.4/bin/ruby_executable_hooks:22:in `eval'
/Users/schwern/.rvm/gems/ruby-2.7.4/bin/ruby_executable_hooks:22:in `<main>'
Finished in 0.164305999991484 seconds
Lint/Ambiguous trips when
self
is part of the range. I don't see the ambiguity, but I might be wrong.Parenthesis do not help, Lint/Ambiguous is still unhappy.
Parens around
self
makes Lint/Ambiguous happy, but I don't understand why. But now Style/RedundantParentheses is unhappy.rubocop -A
goes into an infinite loop between Lint/AmbiguousRange and Style/RedundantParentheses.Expected behavior
Neither
self..42
nor(self..42)
seem ambiguous to me. I'd expect Lint/Ambiguous to accept either one. If it must be(self)..42
thenStyle/RedundantParentheses
would be made to accept that.Actual behavior
Infinite loop between Lint/AmbiguousRange and Style/RedundantParenthesis.
Steps to reproduce the problem
Enable Lint/AmbiguousRange.
RuboCop version
The text was updated successfully, but these errors were encountered: