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, with a code sample #12307

Closed
fdr opened this issue Oct 25, 2023 · 0 comments · Fixed by #12308
Closed

Infinite loop, with a code sample #12307

fdr opened this issue Oct 25, 2023 · 0 comments · Fixed by #12308
Labels

Comments

@fdr
Copy link

fdr commented Oct 25, 2023

Formatting this code crashes:

Struct.new(:sym) {
  def self.ident
    new case expr
        when expr
        end.intern
  end
}

Expected behavior

It shouldn't have crashed.

Actual behavior

It crashed. Here's the output from --debug

For /Users/fdr/code/clover: configuration from /Users/fdr/code/clover/.rubocop.yml
configuration from /Users/fdr/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-capybara-2.19.0/config/default.yml
Default configuration from /Users/fdr/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.56.4/config/default.yml
configuration from /Users/fdr/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-capybara-2.19.0/lib/../config/default.yml
configuration from /Users/fdr/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-erb-0.3.0/config/default.yml
configuration from /Users/fdr/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-performance-1.19.1/config/default.yml
configuration from /Users/fdr/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-performance-1.19.1/config/default.yml
configuration from /Users/fdr/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-rake-0.6.0/config/default.yml
configuration from /Users/fdr/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-rake-0.6.0/config/default.yml
configuration from /Users/fdr/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-factory_bot-2.24.0/config/default.yml
configuration from /Users/fdr/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-factory_bot-2.24.0/lib/../config/default.yml
configuration from /Users/fdr/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-rspec-2.24.1/config/default.yml
configuration from /Users/fdr/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-rspec-2.24.1/config/default.yml
Inheriting configuration from /Users/fdr/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/standard-1.31.2/config/base.yml
Use parallel by default.
Skipping parallel inspection: only a single file needs inspection
Inspecting 1 file
Scanning /Users/fdr/code/clover/rhizome/common/lib/arch.rb
Loading cache from /Users/fdr/.cache/rubocop_cache/35e7e837617d12e3f78219a235caa54153ab8a80/6d7a3b621ca1730e04accd938619e4bdab66cfb1/25e9d8f37b70478b705e209c9232d01e09abd8da
W

Offenses:

rhizome/common/lib/arch.rb:7:9: W: [Corrected] Layout/EndAlignment: end at 7, 8 is not aligned with new case at 5, 4.
        end.intern
        ^^^

0 files inspected, 1 offense detected, 1 offense corrected
Infinite loop detected in /Users/fdr/code/clover/rhizome/common/lib/arch.rb and caused by Layout/EndAlignment
/Users/fdr/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.56.4/lib/rubocop/runner.rb:332:in `check_for_infinite_loop'
/Users/fdr/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.56.4/lib/rubocop/runner.rb:315:in `block in iterate_until_no_changes'
/Users/fdr/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.56.4/lib/rubocop/runner.rb:314:in `loop'
/Users/fdr/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.56.4/lib/rubocop/runner.rb:314:in `iterate_until_no_changes'
/Users/fdr/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.56.4/lib/rubocop/runner.rb:283:in `do_inspection_loop'
/Users/fdr/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.56.4/lib/rubocop/runner.rb:164:in `block in file_offenses'
/Users/fdr/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.56.4/lib/rubocop/runner.rb:189:in `file_offense_cache'
/Users/fdr/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.56.4/lib/rubocop/runner.rb:163:in `file_offenses'
/Users/fdr/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.56.4/lib/rubocop/runner.rb:154:in `process_file'
/Users/fdr/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.56.4/lib/rubocop/runner.rb:135:in `block in each_inspected_file'
/Users/fdr/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.56.4/lib/rubocop/runner.rb:134:in `each'
/Users/fdr/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.56.4/lib/rubocop/runner.rb:134:in `reduce'
/Users/fdr/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.56.4/lib/rubocop/runner.rb:134:in `each_inspected_file'
/Users/fdr/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.56.4/lib/rubocop/runner.rb:120:in `inspect_files'
/Users/fdr/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.56.4/lib/rubocop/runner.rb:73:in `run'
/Users/fdr/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.56.4/lib/rubocop/cli/command/execute_runner.rb:26:in `block in execute_runner'
/Users/fdr/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.56.4/lib/rubocop/cli/command/execute_runner.rb:52:in `with_redirect'
/Users/fdr/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.56.4/lib/rubocop/cli/command/execute_runner.rb:25:in `execute_runner'
/Users/fdr/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.56.4/lib/rubocop/cli/command/execute_runner.rb:17:in `run'
/Users/fdr/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.56.4/lib/rubocop/cli/command.rb:11:in `run'
/Users/fdr/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.56.4/lib/rubocop/cli/environment.rb:18:in `run'
/Users/fdr/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.56.4/lib/rubocop/cli.rb:118:in `run_command'
/Users/fdr/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.56.4/lib/rubocop/cli.rb:125:in `execute_runners'
/Users/fdr/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.56.4/lib/rubocop/cli.rb:51:in `block in run'
/Users/fdr/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.56.4/lib/rubocop/cli.rb:77:in `profile_if_needed'
/Users/fdr/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.56.4/lib/rubocop/cli.rb:43:in `run'
/Users/fdr/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.56.4/exe/rubocop:19:in `block in <top (required)>'
[...]

Steps to reproduce the problem

Put the code sample into a file, and run rubocop -A on that file.

RuboCop version

1.56.4 (using Parser 3.2.2.4, rubocop-ast 1.29.0, running on ruby 3.2.2) [arm64-darwin22]
  - rubocop-capybara 2.19.0
  - rubocop-erb 0.3.0
  - rubocop-performance 1.19.1
  - rubocop-rake 0.6.0
  - rubocop-rspec 2.24.1
  - rubocop-sequel 0.3.4
@koic koic added the bug label Oct 25, 2023
koic added a commit to koic/rubocop that referenced this issue Oct 25, 2023
Fixes rubocop#12307.

This PR fixes an infinite loop error for `Layout/EndAlignment`
when `EnforcedStyleAlignWith: variable` and using a conditional statement in
a method argument on the same line and `end` with method call is not aligned.
bbatsov pushed a commit that referenced this issue Oct 25, 2023
Fixes #12307.

This PR fixes an infinite loop error for `Layout/EndAlignment`
when `EnforcedStyleAlignWith: variable` and using a conditional statement in
a method argument on the same line and `end` with method call is not aligned.
fdr added a commit to ubicloud/ubicloud that referenced this issue Nov 8, 2023
Previously this triggered an infinite loop in rubocop, but we just had
the opportunity (given the `standard` gem) to upgrade to the newest
version that fixes it.

I reported that bug: rubocop/rubocop#12307
fdr added a commit to ubicloud/ubicloud that referenced this issue Nov 8, 2023
Previously this triggered an infinite loop in rubocop, but we just had
the opportunity (given the `standard` gem) to upgrade to the newest
version that fixes it.

I reported that bug: rubocop/rubocop#12307
fdr added a commit to ubicloud/ubicloud that referenced this issue Nov 8, 2023
Previously this triggered an infinite loop in rubocop, but we just had
the opportunity (given the `standard` gem) to upgrade to the newest
version that fixes it.

I reported that bug: rubocop/rubocop#12307
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants