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/AssignmentIndentation vs Layout/FirstArgumentIndentation confuse each other #9434

Closed
zverok opened this issue Jan 28, 2021 · 0 comments

Comments

@zverok
Copy link
Contributor

zverok commented Jan 28, 2021

We have (a bit unusual, I agree) this setting:

Layout/AssignmentIndentation:
  IndentationWidth: 4

(The reasoning of person who introduced this is "not to mix assignments with new block starts").

Now, considering these two cases:

# 1
foo =
    bar
# 2
foo.baz =
    bar

(1) is OK (4 spaces indentation). (2) is OK with this cop, but ...

C: [Correctable] Layout/FirstArgumentIndentation: Indent the first argument one step more than the start of the previous line.
    bar
    ^^^

And if you try to auto-correct it...

rbcp.rb:10:3: C: [Corrected] Layout/AssignmentIndentation: Indent the first line of the right-hand-side of a multi-line assignment.
  bar
  ^^^
rbcp.rb:10:5: C: [Corrected] Layout/FirstArgumentIndentation: Indent the first argument one step more than the start of the previous line.
    bar
    ^^^

0 files inspected, 2 offenses detected, 2 offenses corrected
Infinite loop detected in /home/zverok/playground/ruby/rbcp.rb and caused by Layout/FirstArgumentIndentation -> Layout/AssignmentIndentation

I understand where it comes from (this statement is kinda both "assignment" and "method call"), but it seems to me that the "assignment" should take a priority here... And in any case, infinite loop seems the sub-optimal behavior :)

@koic koic closed this as completed in 83e2b6a Jul 10, 2021
koic added a commit that referenced this issue Jul 10, 2021
[Fix #9434] Fix false positive in FirstArgumentIndentation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant