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 caused by Layout/ArgumentAlignment -> Layout/HashAlignment #10665

Closed
Zopolis4 opened this issue May 24, 2022 · 1 comment · Fixed by #10666
Closed

Infinite loop caused by Layout/ArgumentAlignment -> Layout/HashAlignment #10665

Zopolis4 opened this issue May 24, 2022 · 1 comment · Fixed by #10666
Labels

Comments

@Zopolis4
Copy link

Zopolis4 commented May 24, 2022

Expected behavior

I expected rubocop not to crash.

Actual behavior

Rubocop crashed on an infinite loop caused by Layout/ArgumentAlignment -> Layout/HashAlignment:

rubocop -a -c .rubocop.yml --debug
...
lib/package.rb:25:24: C: [Corrected] Layout/ArgumentAlignment: Align the arguments of a method call if they span more than one line.
                       componentFileFilter: { 'all' => nil },
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
lib/package.rb:25:30: C: [Corrected] Layout/HashAlignment: Align the separators of a hash literal if they span more than one line.
                             componentFileFilter: { 'all' => nil },
                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
lib/package.rb:26:28: C: [Corrected] Layout/ArgumentAlignment: Align the arguments of a method call if they span more than one line.
                           componentOption: { 'all' => { run_postinstall: true } },
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
lib/package.rb:26:30: C: [Corrected] Layout/HashAlignment: Align the separators of a hash literal if they span more than one line.
                             componentOption: { 'all' => { run_postinstall: true } },
                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
lib/package.rb:27:28: C: [Corrected] Layout/ArgumentAlignment: Align the arguments of a method call if they span more than one line.
                           descriptionList: {}
                           ^^^^^^^^^^^^^^^^^^^
lib/package.rb:27:30: C: [Corrected] Layout/HashAlignment: Align the separators of a hash literal if they span more than one line.
                             descriptionList: {}
                             ^^^^^^^^^^^^^^^^^^^

8 files inspected, 221 offenses detected, 6 offenses corrected, 105 more offenses can be corrected with `rubocop -A`
Infinite loop detected in /home/zopolis4/chromebrew/lib/package.rb and caused by Layout/ArgumentAlignment -> Layout/HashAlignment
/var/lib/gems/2.7.0/gems/rubocop-1.29.1/lib/rubocop/runner.rb:296:in `check_for_infinite_loop'
/var/lib/gems/2.7.0/gems/rubocop-1.29.1/lib/rubocop/runner.rb:279:in `block in iterate_until_no_changes'
/var/lib/gems/2.7.0/gems/rubocop-1.29.1/lib/rubocop/runner.rb:278:in `loop'
/var/lib/gems/2.7.0/gems/rubocop-1.29.1/lib/rubocop/runner.rb:278:in `iterate_until_no_changes'
/var/lib/gems/2.7.0/gems/rubocop-1.29.1/lib/rubocop/runner.rb:247:in `do_inspection_loop'
/var/lib/gems/2.7.0/gems/rubocop-1.29.1/lib/rubocop/runner.rb:130:in `block in file_offenses'
/var/lib/gems/2.7.0/gems/rubocop-1.29.1/lib/rubocop/runner.rb:155:in `file_offense_cache'
/var/lib/gems/2.7.0/gems/rubocop-1.29.1/lib/rubocop/runner.rb:129:in `file_offenses'
/var/lib/gems/2.7.0/gems/rubocop-1.29.1/lib/rubocop/runner.rb:120:in `process_file'
/var/lib/gems/2.7.0/gems/rubocop-1.29.1/lib/rubocop/runner.rb:101:in `block in each_inspected_file'
/var/lib/gems/2.7.0/gems/rubocop-1.29.1/lib/rubocop/runner.rb:100:in `each'
/var/lib/gems/2.7.0/gems/rubocop-1.29.1/lib/rubocop/runner.rb:100:in `reduce'
/var/lib/gems/2.7.0/gems/rubocop-1.29.1/lib/rubocop/runner.rb:100:in `each_inspected_file'
/var/lib/gems/2.7.0/gems/rubocop-1.29.1/lib/rubocop/runner.rb:86:in `inspect_files'
/var/lib/gems/2.7.0/gems/rubocop-1.29.1/lib/rubocop/runner.rb:47:in `run'
/var/lib/gems/2.7.0/gems/rubocop-1.29.1/lib/rubocop/cli/command/execute_runner.rb:26:in `block in execute_runner'
/var/lib/gems/2.7.0/gems/rubocop-1.29.1/lib/rubocop/cli/command/execute_runner.rb:52:in `with_redirect'
/var/lib/gems/2.7.0/gems/rubocop-1.29.1/lib/rubocop/cli/command/execute_runner.rb:25:in `execute_runner'
/var/lib/gems/2.7.0/gems/rubocop-1.29.1/lib/rubocop/cli/command/execute_runner.rb:17:in `run'
/var/lib/gems/2.7.0/gems/rubocop-1.29.1/lib/rubocop/cli/command.rb:11:in `run'
/var/lib/gems/2.7.0/gems/rubocop-1.29.1/lib/rubocop/cli/environment.rb:18:in `run'
/var/lib/gems/2.7.0/gems/rubocop-1.29.1/lib/rubocop/cli.rb:71:in `run_command'
/var/lib/gems/2.7.0/gems/rubocop-1.29.1/lib/rubocop/cli.rb:78:in `execute_runners'
/var/lib/gems/2.7.0/gems/rubocop-1.29.1/lib/rubocop/cli.rb:47:in `run'
/var/lib/gems/2.7.0/gems/rubocop-1.29.1/exe/rubocop:12:in `block in <top (required)>'
/usr/lib/ruby/2.7.0/benchmark.rb:308:in `realtime'
/var/lib/gems/2.7.0/gems/rubocop-1.29.1/exe/rubocop:12:in `<top (required)>'
/usr/local/bin/rubocop:23:in `load'
/usr/local/bin/rubocop:23:in `<main>'
Finished in 2.2580198920004477 seconds

The broken area of code in question:

  class << self
    attr_reader_with_default componentList: ['all'],
                       componentFileFilter: { 'all' => nil },
                           componentOption: { 'all' => { run_postinstall: true } },
                           descriptionList: {}

    attr_accessor :name, :is_dep, :in_build, :build_from_source, :in_upgrade, :target_component
  end

The contents of the rubocop.yml file:

AllCops:
  NewCops: enable
  TargetRubyVersion: 3.0

Layout/HashAlignment:
  EnforcedHashRocketStyle:
    - separator
  EnforcedColonStyle:
    - separator

Layout/FirstHashElementIndentation:
  EnforcedStyle: consistent

Style/FrozenStringLiteralComment:
  Enabled: false

Style/Documentation:
  Enabled: false

Naming/VariableNumber:
  Enabled: false

Naming/ClassAndModuleCamelCase:
  Enabled: false

Metrics/MethodLength:
  Enabled: false

Layout/LineLength:
  AllowedPatterns: ['description']

RuboCop version

1.29.1 (using Parser 3.1.2.0, rubocop-ast 1.18.0, running on ruby 2.7.4 x86_64-linux-gnu)
@koic koic added the bug label May 24, 2022
@Zopolis4
Copy link
Author

Seems to be a cache issue of some sort, it resolved itself after changing the TargetRubyVersion a couple times and then reverting the changes.

koic added a commit to koic/rubocop that referenced this issue May 25, 2022
…Alignment`

Fixes rubocop#10665.

This PR fixes an incorrect autocorrect for `EnforcedStyle: with_first_argument` of
`Layout/ArgumentAlignment` and `EnforcedColonStyle: separator` of `Layout/HashAlignment`.
bbatsov pushed a commit that referenced this issue May 26, 2022
Fixes #10665.

This PR fixes an incorrect autocorrect for `EnforcedStyle: with_first_argument` of
`Layout/ArgumentAlignment` and `EnforcedColonStyle: separator` of `Layout/HashAlignment`.
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