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
We're seeing an issue with the Style/IfUnlessModifier cop getting in an infinite loop on a long line (seemingly switching between the single-line and multi-line versions).
This started happening on v0.83.0; no violations were reported on v0.82.0.
.rubocop.yml
Layout/LineLength:
Max: 90
example.rb
# frozen_string_literal: true<<~FOO.strip#{'Lorem ipsum dolor sit amet, consectetur adipiscing elit vivamus mollis.'ifcount > 1}FOO
Expected behavior
To terminate without an infinite loop.
Actual behavior
Rubocop exits with code 2, and the following output:
$ bundle exec rubocop -a
The following cops were added to RuboCop, but are not configured. Please set Enabled to either `true` or `false` in your `.rubocop.yml` file:
- Layout/EmptyLinesAroundAttributeAccessor (0.83)
- Layout/SpaceAroundMethodCallOperator (0.82)
- Lint/RaiseException (0.81)
- Lint/StructNewOverride (0.81)
- Style/ExponentialNotation (0.82)
- Style/HashEachMethods (0.80)
- Style/HashTransformKeys (0.80)
- Style/HashTransformValues (0.80)
- Style/SlicingWithRange (0.83)
For more information: https://docs.rubocop.org/en/latest/versioning/
Inspecting 2 files
.C
Offenses:
example.rb:4:5: C: [Corrected] Style/IfUnlessModifier: Favor modifier if usage when having a single-line body. Another good alternative is the usage of control flow &&/||.
#{if count > 1
^^
example.rb:4:79: C: [Corrected] Style/IfUnlessModifier: Modifier form of if makes the line too long.
#{'Lorem ipsum dolor sit amet, consectetur adipiscing elit vivamus mollis.' if count > 1}
^^
1 file inspected, 2 offenses detected, 2 offenses corrected
Infinite loop detected in /private/tmp/rubocop/example.rb.
/Users/mthomson/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/rubocop-0.83.0/lib/rubocop/runner.rb:292:in `check_for_infinite_loop'
/Users/mthomson/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/rubocop-0.83.0/lib/rubocop/runner.rb:275:in `block in iterate_until_no_changes'
/Users/mthomson/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/rubocop-0.83.0/lib/rubocop/runner.rb:274:in `loop'
/Users/mthomson/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/rubocop-0.83.0/lib/rubocop/runner.rb:274:in `iterate_until_no_changes'
/Users/mthomson/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/rubocop-0.83.0/lib/rubocop/runner.rb:245:in `do_inspection_loop'
/Users/mthomson/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/rubocop-0.83.0/lib/rubocop/runner.rb:124:in `block in file_offenses'
/Users/mthomson/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/rubocop-0.83.0/lib/rubocop/runner.rb:148:in `file_offense_cache'
/Users/mthomson/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/rubocop-0.83.0/lib/rubocop/runner.rb:122:in `file_offenses'
/Users/mthomson/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/rubocop-0.83.0/lib/rubocop/runner.rb:113:in `process_file'
/Users/mthomson/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/rubocop-0.83.0/lib/rubocop/runner.rb:92:in `block in each_inspected_file'
/Users/mthomson/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/rubocop-0.83.0/lib/rubocop/runner.rb:91:in `each'
/Users/mthomson/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/rubocop-0.83.0/lib/rubocop/runner.rb:91:in `reduce'
/Users/mthomson/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/rubocop-0.83.0/lib/rubocop/runner.rb:91:in `each_inspected_file'
/Users/mthomson/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/rubocop-0.83.0/lib/rubocop/runner.rb:78:in `inspect_files'
/Users/mthomson/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/rubocop-0.83.0/lib/rubocop/runner.rb:39:in `run'
/Users/mthomson/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/rubocop-0.83.0/lib/rubocop/cli/command/execute_runner.rb:21:in `execute_runner'
/Users/mthomson/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/rubocop-0.83.0/lib/rubocop/cli/command/execute_runner.rb:13:in `run'
/Users/mthomson/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/rubocop-0.83.0/lib/rubocop/cli/command.rb:10:in `run'
/Users/mthomson/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/rubocop-0.83.0/lib/rubocop/cli/environment.rb:17:in `run'
/Users/mthomson/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/rubocop-0.83.0/lib/rubocop/cli.rb:65:in `run_command'
/Users/mthomson/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/rubocop-0.83.0/lib/rubocop/cli.rb:72:in `execute_runners'
/Users/mthomson/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/rubocop-0.83.0/lib/rubocop/cli.rb:41:in `run'
/Users/mthomson/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/rubocop-0.83.0/exe/rubocop:13:in `block in <top (required)>'
/Users/mthomson/.rbenv/versions/2.6.6/lib/ruby/2.6.0/benchmark.rb:308:in `realtime'
/Users/mthomson/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/rubocop-0.83.0/exe/rubocop:12:in `<top (required)>'
/Users/mthomson/.rbenv/versions/2.6.6/bin/rubocop:23:in `load'
/Users/mthomson/.rbenv/versions/2.6.6/bin/rubocop:23:in `<top (required)>'
/Users/mthomson/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/cli/exec.rb:63:in `load'
/Users/mthomson/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/cli/exec.rb:63:in `kernel_load'
/Users/mthomson/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/cli/exec.rb:28:in `run'
/Users/mthomson/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/cli.rb:476:in `exec'
/Users/mthomson/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
/Users/mthomson/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
/Users/mthomson/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor.rb:399:in `dispatch'
/Users/mthomson/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/cli.rb:30:in `dispatch'
/Users/mthomson/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor/base.rb:476:in `start'
/Users/mthomson/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/cli.rb:24:in `start'
/Users/mthomson/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/exe/bundle:46:in `block in <top (required)>'
/Users/mthomson/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/friendly_errors.rb:123:in `with_friendly_errors'
/Users/mthomson/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/exe/bundle:34:in `<top (required)>'
/Users/mthomson/.rbenv/versions/2.6.6/bin/bundle:23:in `load'
/Users/mthomson/.rbenv/versions/2.6.6/bin/bundle:23:in `<main>'
Steps to reproduce the problem
Set up files as in description above, and run bundle exec rubocop -a.
We're seeing an issue with the
Style/IfUnlessModifier
cop getting in an infinite loop on a long line (seemingly switching between the single-line and multi-line versions).This started happening on v0.83.0; no violations were reported on v0.82.0.
.rubocop.yml
example.rb
Expected behavior
To terminate without an infinite loop.
Actual behavior
Rubocop exits with code 2, and the following output:
Steps to reproduce the problem
Set up files as in description above, and run
bundle exec rubocop -a
.RuboCop version
The text was updated successfully, but these errors were encountered: