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 indented breaks down with method call before assignment #10456

Closed
AlexWayfer opened this issue Mar 18, 2022 · 1 comment · Fixed by #10458
Labels

Comments

@AlexWayfer
Copy link
Contributor

AlexWayfer commented Mar 18, 2022

Expected behavior

No offenses from Layout/MultilineMethodCallIndentation.

Actual behavior

Offense per each line from Layout/MultilineMethodCallIndentation.

For /home/alex/Projects/ruby/test/rubocop/method_chaining: configuration from /home/alex/Projects/ruby/test/rubocop/method_chaining/.rubocop.yml
Default configuration from /home/alex/.rbenv/versions/3.1.1/lib/ruby/gems/3.1.0/gems/rubocop-1.26.0/config/default.yml
AllCops/Exclude configuration from /home/alex/Projects/ruby/test/.rubocop.yml
Use parallel by default.
Running parallel inspection
Inspecting 1 file
Scanning /home/alex/Projects/ruby/test/rubocop/method_chaining/test.rb
Loading cache from /home/alex/.cache/rubocop_cache/4c137b0d5f5d8fdbc0e9bb4b9f6dd0b1df7fe331/2d086c9a02b07de22b92121fa4e42b028afffdec/7d4ab545ae940e92d10de1093604eedb0b3bd020
C

Offenses:

test.rb:5:5: C: [Correctable] Layout/MultilineMethodCallIndentation: Use 2 (not 4) spaces for indenting an expression in an assignment spanning multiple lines.
    .gsub(/\s+(?=$)/, '')
    ^^^^^
test.rb:6:5: C: [Correctable] Layout/MultilineMethodCallIndentation: Use 2 (not 4) spaces for indenting an expression in an assignment spanning multiple lines.
    .gsub(/([,;]|\.{2,})(?=$)/, '.')
    ^^^^^

1 file inspected, 2 offenses detected, 2 offenses auto-correctable
Finished in 0.13953729800050496 seconds

Steps to reproduce the problem

# .rubocop.yml

AllCops:
  NewCops: enable

Layout/MultilineMethodCallIndentation:
  EnforcedStyle: indented
# frozen_string_literal: true

self.bar =
  baz
    .gsub(/\s+(?=$)/, '')
    .gsub(/([,;]|\.{2,})(?=$)/, '.')

(just removing self. leads to no offenses)

RuboCop version

Include the output of rubocop -V or bundle exec rubocop -V if using Bundler.
If you see extension cop versions (e.g. rubocop-performance, rubocop-rspec, and others)
output by rubocop -V, include them as well. Here's an example:

1.26.0 (using Parser 3.1.1.0, rubocop-ast 1.16.0, running on ruby 3.1.1 x86_64-linux)
@koic koic added the bug label Mar 18, 2022
koic added a commit to koic/rubocop that referenced this issue Mar 18, 2022
…allIndentation`

Fixes rubocop#10456.

This PR fixes a false positive for `Layout/MultilineMethodCallIndentation`
when using `EnforcedStyle: indented` with indented assignment method.
koic added a commit that referenced this issue Mar 19, 2022
…tiline_method_call_indentation

[Fix #10456] Fix a false positive for `Layout/MultilineMethodCallIndentation`
@AlexWayfer
Copy link
Contributor Author

@koic thank you, I appreciate your work! 🙌

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