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/ArgumentAlignment vs Layout/HashAlignment #9490

Closed
one0fnine opened this issue Feb 3, 2021 · 0 comments · Fixed by #9491
Closed

Layout/ArgumentAlignment vs Layout/HashAlignment #9490

one0fnine opened this issue Feb 3, 2021 · 0 comments · Fixed by #9491
Labels

Comments

@one0fnine
Copy link

one0fnine commented Feb 3, 2021

Hi folks.
I found out odd rubocop behavior. in case when it fix alignments of method attributes
Looks. A just code example

def do_even_more_stuff
  foo = begin
do_stuff(
            a: 1,
                   b: 2,
                   c: 3
                  )
                        rescue StandardError
                 nil
end
  foo
end

My rubocop settings:

AllCops:
  TargetRubyVersion: 3.0
  DisabledByDefault: true
  Exclude: []

Layout/ArgumentAlignment:
  Enabled: true
  EnforcedStyle: with_fixed_indentation

And that's it.

Rubocop is finding no issues.
Although It should change alignment of a, b, c arguments.

Next, i changed the config:

AllCops:
  TargetRubyVersion: 3.0
  DisabledByDefault: true
  Exclude: []

Layout/HashAlignment:
  Enabled: true
  EnforcedHashRocketStyle: key
  EnforcedColonStyle: key
  EnforcedLastArgumentHashStyle: always_inspect

And It found issues : Layout/HashAlignment: Align the keys of a hash literal if they span more than one line
I usually use -A argument to fix their. So I got followed result:

def do_even_more_stuff
  foo = begin
do_stuff(
            a: 1,
            b: 2,
            c: 3
                  )
                        rescue StandardError
                 nil
end
  foo
end

I suppose the alignment of attributes is wrong.

$ bundle exec rubocop -V
1.9.1 (using Parser 3.0.0.0, rubocop-ast 1.4.1, running on ruby 3.0.0 x86_64-darwin19)
  - rubocop-performance 1.9.2
@koic koic added the bug label Feb 3, 2021
koic added a commit to koic/rubocop that referenced this issue Feb 3, 2021
…ntIndentation`

Fixes rubocop#9490 and a regression of rubocop#9486.

This PR fixes incorrect auto-correct for `Layout/FirstArgumentIndentation`
when specifying `EnforcedStyle: with_fixed_indentation` of `Layout/ArgumentAlignment` and
`EnforcedStyle: consistent` of `Layout/FirstArgumentIndentation`.

And this resolves the following Standard gem build error when upgrading to RuboCop 1.9.1.

```console
2) Failure:
Standard::CliTest#test_autocorrectable
[/home/runner/work/standard/standard/test/standard/cli_test.rb:14]:
--- expected
+++ actual
@@ -98,13 +98,13 @@
```

https://github.com/testdouble/standard/runs/1805630903
bbatsov pushed a commit that referenced this issue Feb 4, 2021
…tation`

Fixes #9490 and a regression of #9486.

This PR fixes incorrect auto-correct for `Layout/FirstArgumentIndentation`
when specifying `EnforcedStyle: with_fixed_indentation` of `Layout/ArgumentAlignment` and
`EnforcedStyle: consistent` of `Layout/FirstArgumentIndentation`.

And this resolves the following Standard gem build error when upgrading to RuboCop 1.9.1.

```console
2) Failure:
Standard::CliTest#test_autocorrectable
[/home/runner/work/standard/standard/test/standard/cli_test.rb:14]:
--- expected
+++ actual
@@ -98,13 +98,13 @@
```

https://github.com/testdouble/standard/runs/1805630903
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