Skip to content
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

Infinite loop when fixed indentation is set for both Layout/ArrayAlignment and Layout/AssignmentIndentation #8774

Closed
searls opened this issue Sep 23, 2020 · 1 comment · Fixed by #8780
Labels

Comments

@searls
Copy link

searls commented Sep 23, 2020

I just found an infinite loop bug that affect's standard's configuration. Minimal repro steps:

Given file listing foo.rb:

thing, foo =
    1, 2

and config.yml:

Layout/ArrayAlignment:
  Enabled: true
  EnforcedStyle: with_fixed_indentation

Layout/AssignmentIndentation:
  Enabled: true
  IndentationWidth: ~

and running this autocorrect command:

rubocop -a --config config.yml --only "Layout/ArrayAlignment,Layout/AssignmentIndentation" foo.rb

You get this infinite loop output:

Inspecting 1 file
C

Offenses:

foo.rb:2:5: C: [Corrected] Layout/ArrayAlignment: Use one level of indentation for elements following the first line of a multi-line array.
    1, 2
    ^
foo.rb:2:5: C: [Corrected] Layout/AssignmentIndentation: Indent the first line of the right-hand-side of a multi-line assignment.
    1, 2
    ^^^^

0 files inspected, 2 offenses detected, 2 offenses corrected
Infinite loop detected in /Users/justin/code/testdouble/static-rails/foo.rb and caused by Layout/ArrayAlignment, Layout/AssignmentIndentation
/Users/justin/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rubocop-0.91.1/lib/rubocop/runner.rb:300:in `check_for_infinite_loop'
/Users/justin/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rubocop-0.91.1/lib/rubocop/runner.rb:283:in `block in iterate_until_no_changes'
/Users/justin/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rubocop-0.91.1/lib/rubocop/runner.rb:282:in `loop'
/Users/justin/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rubocop-0.91.1/lib/rubocop/runner.rb:282:in `iterate_until_no_changes'
/Users/justin/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rubocop-0.91.1/lib/rubocop/runner.rb:251:in `do_inspection_loop'
/Users/justin/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rubocop-0.91.1/lib/rubocop/runner.rb:128:in `block in file_offenses'
/Users/justin/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rubocop-0.91.1/lib/rubocop/runner.rb:153:in `file_offense_cache'
/Users/justin/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rubocop-0.91.1/lib/rubocop/runner.rb:127:in `file_offenses'
/Users/justin/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rubocop-0.91.1/lib/rubocop/runner.rb:118:in `process_file'
/Users/justin/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rubocop-0.91.1/lib/rubocop/runner.rb:97:in `block in each_inspected_file'
/Users/justin/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rubocop-0.91.1/lib/rubocop/runner.rb:96:in `each'
/Users/justin/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rubocop-0.91.1/lib/rubocop/runner.rb:96:in `reduce'
/Users/justin/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rubocop-0.91.1/lib/rubocop/runner.rb:96:in `each_inspected_file'
/Users/justin/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rubocop-0.91.1/lib/rubocop/runner.rb:82:in `inspect_files'
/Users/justin/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rubocop-0.91.1/lib/rubocop/runner.rb:43:in `run'
/Users/justin/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rubocop-0.91.1/lib/rubocop/cli/command/execute_runner.rb:25:in `execute_runner'
/Users/justin/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rubocop-0.91.1/lib/rubocop/cli/command/execute_runner.rb:17:in `run'
/Users/justin/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rubocop-0.91.1/lib/rubocop/cli/command.rb:11:in `run'
/Users/justin/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rubocop-0.91.1/lib/rubocop/cli/environment.rb:18:in `run'
/Users/justin/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rubocop-0.91.1/lib/rubocop/cli.rb:65:in `run_command'
/Users/justin/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rubocop-0.91.1/lib/rubocop/cli.rb:72:in `execute_runners'
/Users/justin/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rubocop-0.91.1/lib/rubocop/cli.rb:41:in `run'
/Users/justin/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rubocop-0.91.1/exe/rubocop:13:in `block in <top (required)>'
/Users/justin/.rbenv/versions/2.7.1/lib/ruby/2.7.0/benchmark.rb:308:in `realtime'
/Users/justin/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rubocop-0.91.1/exe/rubocop:12:in `<top (required)>'
/Users/justin/.rbenv/versions/2.7.1/bin/rubocop:23:in `load'
/Users/justin/.rbenv/versions/2.7.1/bin/rubocop:23:in `<main>'

Versions:

$ rubocop -v
0.91.1
$ ruby -v
ruby 2.7.1p83 (2020-03-31 revision a0c7c23c9c) [x86_64-darwin19]
@koic koic added the bug label Sep 23, 2020
dvandersluis added a commit to dvandersluis/rubocop that referenced this issue Sep 23, 2020
koic added a commit that referenced this issue Sep 24, 2020
…ntation-infinite-loop

[Fix #8774] Fix false positive with `Layout/ArrayAlignment` for parallel assignment
@searls
Copy link
Author

searls commented Sep 24, 2020

Wow, what a fast turnaround! Amazing work @dvandersluis, and thanks @koic!! ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
2 participants