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

Layout/LineLength and some cops causes infinite loop #10700

Closed
nobuyo opened this issue Jun 7, 2022 · 0 comments · Fixed by #10742
Closed

Layout/LineLength and some cops causes infinite loop #10700

nobuyo opened this issue Jun 7, 2022 · 0 comments · Fixed by #10742

Comments

@nobuyo
Copy link
Contributor

nobuyo commented Jun 7, 2022

Originally reported: #10692 (comment), #10692 (comment)


Expected behavior

Run RuboCop without errors.

Actual behavior

Infinite loop is occured.

Steps to reproduce the problem

  1. Create files
  2. Run RuboCop
# .rubocop.yml
AllCops:
  NewCops: enable
  TargetRubyVersion: 3.1

Layout/LineLength:
  Max: 40
# example.rb
def foo(abc: '100000', def: '100000', ghi: '100000', jkl: '100000', mno: '100000'); end
$ bundle exec rubocop -a example.rb
Inspecting 1 file
W

Offenses:

example.rb:1:1: C: [Corrected] Style/EmptyMethod: Put empty method definitions on a single line.
def foo(abc: '100000', def: '100000', ghi: '100000', jkl: '100000', mno: '100000'); ...
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
example.rb:1:38: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected.
def foo(abc: '100000', def: '100000',
                                     ^
example.rb:1:41: C: [Corrected] Layout/LineLength: Line is too long. [83/40]
def foo(abc: '100000', def: '100000', ghi: '100000', jkl: '100000', mno: '100000');
                                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
example.rb:1:41: C: [Corrected] Layout/LineLength: Line is too long. [87/40]
def foo(abc: '100000', def: '100000', ghi: '100000', jkl: '100000', mno: '100000'); end
                                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
example.rb:1:83: C: [Corrected] Style/Semicolon: Do not use semicolons to terminate expressions.
def foo(abc: '100000', def: '100000', ghi: '100000', jkl: '100000', mno: '100000');
                                                                                  ^
example.rb:2:1: C: [Corrected] Layout/ParameterAlignment: Align the parameters of a method definition if they span more than one line.
ghi: '100000', jkl: '100000', mno: '100000')
^^^^^^^^^^^^^
example.rb:2:2: W: [Corrected] Layout/DefEndAlignment: end at 2, 1 is not aligned with def at 1, 0.
 end
 ^^^
example.rb:2:41: C: Layout/LineLength: Line is too long. [52/40]
        ghi: '100000', jkl: '100000', mno: '100000')
                                        ^^^^^^^^^^^^

0 files inspected, 8 offenses detected, 7 offenses corrected
Infinite loop detected in /Users/nobuyo/dev/rubocop-test/example.rb and caused by Layout/LineLength -> Layout/DefEndAlignment, Layout/LineLength, Style/EmptyMethod, Style/Semicolon -> Layout/ParameterAlignment, Layout/TrailingWhitespace, Style/EmptyMethod -> Layout/LineLength, Style/EmptyMethod
/Users/nobuyo/dev/rubocop-korri/lib/rubocop/runner.rb:296:in `check_for_infinite_loop'
/Users/nobuyo/dev/rubocop-korri/lib/rubocop/runner.rb:279:in `block in iterate_until_no_changes'
/Users/nobuyo/dev/rubocop-korri/lib/rubocop/runner.rb:278:in `loop'
/Users/nobuyo/dev/rubocop-korri/lib/rubocop/runner.rb:278:in `iterate_until_no_changes'
/Users/nobuyo/dev/rubocop-korri/lib/rubocop/runner.rb:247:in `do_inspection_loop'
/Users/nobuyo/dev/rubocop-korri/lib/rubocop/runner.rb:130:in `block in file_offenses'
/Users/nobuyo/dev/rubocop-korri/lib/rubocop/runner.rb:155:in `file_offense_cache'
/Users/nobuyo/dev/rubocop-korri/lib/rubocop/runner.rb:129:in `file_offenses'
/Users/nobuyo/dev/rubocop-korri/lib/rubocop/runner.rb:120:in `process_file'
/Users/nobuyo/dev/rubocop-korri/lib/rubocop/runner.rb:101:in `block in each_inspected_file'
/Users/nobuyo/dev/rubocop-korri/lib/rubocop/runner.rb:100:in `each'
/Users/nobuyo/dev/rubocop-korri/lib/rubocop/runner.rb:100:in `reduce'
/Users/nobuyo/dev/rubocop-korri/lib/rubocop/runner.rb:100:in `each_inspected_file'
/Users/nobuyo/dev/rubocop-korri/lib/rubocop/runner.rb:86:in `inspect_files'
/Users/nobuyo/dev/rubocop-korri/lib/rubocop/runner.rb:47:in `run'
/Users/nobuyo/dev/rubocop-korri/lib/rubocop/cli/command/execute_runner.rb:26:in `block in execute_runner'

# ...

RuboCop version

Include the output of rubocop -V or bundle exec rubocop -V if using Bundler.
If you see extension cop versions (e.g. rubocop-performance, rubocop-rspec, and others)
output by rubocop -V, include them as well. Here's an example:

$ [bundle exec] rubocop -V
1.30.1 (using Parser 3.1.2.0, rubocop-ast 1.18.0, running on ruby 3.1.2 x86_64-darwin21)
  - rubocop-performance 1.14.0
  - rubocop-rake 0.6.0
  - rubocop-rspec 2.11.1
dvandersluis added a commit to dvandersluis/rubocop that referenced this issue Jun 22, 2022
…correction would exceed the configuration for `Layout/LineLength`.
bbatsov pushed a commit that referenced this issue Jun 24, 2022
…ion would exceed the configuration for `Layout/LineLength`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant