-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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 detected: Layout/ArgumentAlignment, Layout/ClosingParenthesisIndentation -> Layout/ClosingParenthesisIndentation, Layout/FirstArgumentIndentation #9453
Labels
Comments
koic
added a commit
to koic/rubocop
that referenced
this issue
Feb 1, 2021
…terIndentation` Fixes rubocop#9453. This PR fixes the following infinite loop error for `Layout/FirstParameterIndentation` when `EnforcedStyle: with_fixed_indentation` is specified for `Layout/ArgumentAlignment`. ```console % cat example.rb # frozen_string_literal: true RSpec.describe MyController, type: :controller do it 'abc' do expect(response).to redirect_to(path( obj1, id: obj2.id )) end end % cat .rubocop.yml AllCops: NewCops: enable Layout/ArgumentAlignment: EnforcedStyle: with_fixed_indentation % bundle exec rubocop -a --only Layout/ArgumentAlignment,Layout/FirstArgumentIndentation (snip) Infinite loop detected in /Users/koic/src/github.com/koic/rubocop-issues/9453/example.rb and caused by Layout/FirstArgumentIndentation -> Layout/ArgumentAlignment /Users/koic/src/github.com/rubocop-hq/rubocop/lib/rubocop/runner.rb:304:in `check_for_infinite_loop' /Users/koic/src/github.com/rubocop-hq/rubocop/lib/rubocop/runner.rb:287:in `block in iterate_until_no_changes' ``` The following is the reason why an error occurs. First, `Layout/FirstArgumentIndentation` will auto-correct it. ```console % bundle exec rubocop -a --only Layout/FirstArgumentIndentation Inspecting 1 file C Offenses: example.rb:6:7: C: [Corrected] Layout/FirstArgumentIndentation: Indent the first argument one step more than path(. obj1, ^^^^ 1 file inspected, 1 offense detected, 1 offense corrected % cat example.rb # frozen_string_literal: true RSpec.describe MyController, type: :controller do it 'abc' do expect(response).to redirect_to(path( obj1, id: obj2.id )) end end ``` Next, `Layout/ArgumentAlignment` will auto-correct it. ```consloe % bundle exec rubocop -a --only Layout/ArgumentAlignment Inspecting 1 file C Offenses: example.rb:6:39: C: [Corrected] Layout/ArgumentAlignment: Use one level of indentation for arguments following the first line of a multi-line method call. obj1, ^^^^ 1 file inspected, 1 offense detected, 1 offense corrected % cat example.rb # frozen_string_literal: true RSpec.describe MyController, type: :controller do it 'abc' do expect(response).to redirect_to(path( obj1, id: obj2.id )) end end ``` An infinite loop error occurs because it is corrected to the original code. This PR makes `Layout/FirstParameterIndentation` respect `Layout/ArgumentAlignment` when `EnforcedStyle: with_fixed_indentation` alternative configuration is specified for `Layout/ArgumentAlignment` to prevent the error.
8 tasks
bbatsov
pushed a commit
that referenced
this issue
Feb 1, 2021
…ntation` Fixes #9453. This PR fixes the following infinite loop error for `Layout/FirstParameterIndentation` when `EnforcedStyle: with_fixed_indentation` is specified for `Layout/ArgumentAlignment`. ```console % cat example.rb # frozen_string_literal: true RSpec.describe MyController, type: :controller do it 'abc' do expect(response).to redirect_to(path( obj1, id: obj2.id )) end end % cat .rubocop.yml AllCops: NewCops: enable Layout/ArgumentAlignment: EnforcedStyle: with_fixed_indentation % bundle exec rubocop -a --only Layout/ArgumentAlignment,Layout/FirstArgumentIndentation (snip) Infinite loop detected in /Users/koic/src/github.com/koic/rubocop-issues/9453/example.rb and caused by Layout/FirstArgumentIndentation -> Layout/ArgumentAlignment /Users/koic/src/github.com/rubocop-hq/rubocop/lib/rubocop/runner.rb:304:in `check_for_infinite_loop' /Users/koic/src/github.com/rubocop-hq/rubocop/lib/rubocop/runner.rb:287:in `block in iterate_until_no_changes' ``` The following is the reason why an error occurs. First, `Layout/FirstArgumentIndentation` will auto-correct it. ```console % bundle exec rubocop -a --only Layout/FirstArgumentIndentation Inspecting 1 file C Offenses: example.rb:6:7: C: [Corrected] Layout/FirstArgumentIndentation: Indent the first argument one step more than path(. obj1, ^^^^ 1 file inspected, 1 offense detected, 1 offense corrected % cat example.rb # frozen_string_literal: true RSpec.describe MyController, type: :controller do it 'abc' do expect(response).to redirect_to(path( obj1, id: obj2.id )) end end ``` Next, `Layout/ArgumentAlignment` will auto-correct it. ```consloe % bundle exec rubocop -a --only Layout/ArgumentAlignment Inspecting 1 file C Offenses: example.rb:6:39: C: [Corrected] Layout/ArgumentAlignment: Use one level of indentation for arguments following the first line of a multi-line method call. obj1, ^^^^ 1 file inspected, 1 offense detected, 1 offense corrected % cat example.rb # frozen_string_literal: true RSpec.describe MyController, type: :controller do it 'abc' do expect(response).to redirect_to(path( obj1, id: obj2.id )) end end ``` An infinite loop error occurs because it is corrected to the original code. This PR makes `Layout/FirstParameterIndentation` respect `Layout/ArgumentAlignment` when `EnforcedStyle: with_fixed_indentation` alternative configuration is specified for `Layout/ArgumentAlignment` to prevent the error.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Config
Input
The text was updated successfully, but these errors were encountered: