I'd like to format this code, with bundle exec rubocop --autocorrect
.
module A class B def self.from_key(key, params) new( **params, key:, other: get_other_stuff, ) end end endExpected behavior
Fully indent the key
and other
lines to match the indentation of **params
:
module A class B def self.from_key(key, params) new( **params, key:, other: get_other_stuff, ) end end endActual behavior
There's an error:
Infinite loop detected in /Users/me/myproject/example.rb and caused by Layout/ClosingParenthesisIndentation, Layout/FirstArgumentIndentation, Layout/HashAlignment -> Layout/ArgumentAlignment, Layout/ClosingParenthesisIndentation, Layout/FirstArgumentIndentation -> Layout/ArgumentAlignment, Layout/ClosingParenthesisIndentation, Layout/HashAlignment C Offenses: example.rb:5:8: C: [Corrected] Layout/FirstArgumentIndentation: Indent the first argument one step more than the start of the previous line. **params, ... ^^^^^^^^^ example.rb:5:8: C: [Corrected] Layout/HashAlignment: Align keyword splats with the rest of the hash if it spans more than one line. **params, ^^^^^^^^ example.rb:5:9: C: [Corrected] Layout/HashAlignment: Align keyword splats with the rest of the hash if it spans more than one line. **params, ^^^^^^^^ example.rb:5:10: C: [Corrected] Layout/FirstArgumentIndentation: Indent the first argument one step more than the start of the previous line. **params, ... ^^^^^^^^^ example.rb:6:8: C: [Corrected] Layout/ArgumentAlignment: Use one level of indentation for arguments following the first line of a multi-line method call. key:, ^^^^ example.rb:6:10: C: [Corrected] Layout/ArgumentAlignment: Use one level of indentation for arguments following the first line of a multi-line method call. key:, ^^^^ example.rb:7:8: C: [Corrected] Layout/ArgumentAlignment: Use one level of indentation for arguments following the first line of a multi-line method call. other: get_other_stuff, ^^^^^^^^^^^^^^^^^^^^^^ example.rb:7:10: C: [Corrected] Layout/ArgumentAlignment: Use one level of indentation for arguments following the first line of a multi-line method call. other: get_other_stuff, ^^^^^^^^^^^^^^^^^^^^^^ example.rb:8:6: C: [Corrected] Layout/ClosingParenthesisIndentation: Indent ) to column 7 (not 5) ) ^ example.rb:8:7: C: [Corrected] Layout/ClosingParenthesisIndentation: Indent ) to column 5 (not 6) ) ^ example.rb:8:8: C: [Corrected] Layout/ClosingParenthesisIndentation: Indent ) to column 6 (not 7) ) ^ 1 file inspected, 11 offenses detected, 11 offenses corrected 1 error occurred: Infinite loop detected in /Users/maxnotarangelo/skylight/example.rb and caused by Layout/ClosingParenthesisIndentation, Layout/FirstArgumentIndentation, Layout/HashAlignment -> Layout/ArgumentAlignment, Layout/ClosingParenthesisIndentation, Layout/FirstArgumentIndentation -> Layout/ArgumentAlignment, Layout/ClosingParenthesisIndentation, Layout/HashAlignmentSteps to reproduce the problem
I originally found this in a project with a lot of rubocop configuration, but I was able to reproduce it with a much smaller configuration file (this isn't necessarily the minimal configuration needed to reproduce the error):
AllCops: TargetRubyVersion: 3.3 CacheRootDirectory: ./tmp NewCops: disable Layout/ArgumentAlignment: EnforcedStyle: with_fixed_indentation Layout/ExtraSpacing: Enabled: true Layout/FirstArgumentIndentation: EnforcedStyle: consistent Layout/FirstArrayElementIndentation: EnforcedStyle: consistent Layout/FirstHashElementIndentation: EnforcedStyle: consistent Layout/FirstMethodParameterLineBreak: Enabled: true Layout/HashAlignment: EnforcedHashRocketStyle: key EnforcedColonStyle: key Layout/LineLength: AutoCorrect: false Max: 80 Severity: info Layout/MultilineMethodCallIndentation: EnforcedStyle: indented Layout/ParameterAlignment: EnforcedStyle: with_fixed_indentation Style/TrailingCommaInArguments: EnforcedStyleForMultiline: comma Style/FrozenStringLiteralComment: Enabled: false Style/Documentation: Enabled: falseRuboCop version
$ bundle exec rubocop -V
1.75.6 (using Parser 3.3.7.4, Prism 1.4.0, rubocop-ast 1.44.1, analyzing as Ruby 3.3, running on ruby 3.3.5) [arm64-darwin23]
- rubocop-graphql 1.4.0
- rubocop-performance 1.19.1
- rubocop-rails 2.21.2
- rubocop-rspec 2.24.1
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4