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/MultilineMethodCallIndentation requesting illogical results #10488

Closed
tenpaiyomi opened this issue Mar 29, 2022 · 1 comment · Fixed by #10550
Closed

Layout/MultilineMethodCallIndentation requesting illogical results #10488

tenpaiyomi opened this issue Mar 29, 2022 · 1 comment · Fixed by #10550
Labels

Comments

@tenpaiyomi
Copy link

I'm not sure if this is something that can realistically be "fixed", but wanted to just point out a scenario where Rubocop was throwing an error regarding Layout/MultilineMethodCallIndentation that is entirely illogical and results in less readable and maintainable code.


Expected behavior

I expect Rubocop to enforce Layout/MultilineMethodCallIndentation in a manner that provides clear, concise, logical results for multiline method call indentations, such that the following code would be considered valid:

      expect { post :parse_emails, params: params, format: :json }.to change { Membership.count }.by(0)
                                                                  .and change { Invitation.count }.by(0)
                                                                  .and raise_error(ActiveRecord::RecordInvalid)

Actual behavior

Rubocop expects the indentation to work at the end of each last method call, for each line, cascading down, like so

      expect { post :parse_emails, params: params, format: :json }.to change { Membership.count }.by(0)
                                                                                                 .and change { Invitation.count }.by(0)
                                                                                                                                 .and raise_error(ActiveRecord::RecordInvalid)

Steps to reproduce the problem

See the above code

RuboCop version

1.26.1 (using Parser 3.1.1.0, rubocop-ast 1.16.0, running on ruby 3.1.1 x86_64-linux)
  - rubocop-faker 1.1.0
  - rubocop-performance 1.12.0
  - rubocop-rails 2.14.2
  - rubocop-rspec 2.9.0
@koic koic added the bug label Apr 19, 2022
nobuyo added a commit to nobuyo/rubocop that referenced this issue Apr 19, 2022
…lIndentation` breaks indentation for nesting of method calls
bbatsov pushed a commit that referenced this issue Apr 20, 2022
…ation` breaks indentation for nesting of method calls
@tenpaiyomi
Copy link
Author

Thanks everybody, I greatly appreciate the work you all do.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
2 participants