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 reports false positives if using Ruby 2.7 numbered parameters #7779

Closed
DMA57361 opened this issue Mar 6, 2020 · 0 comments · Fixed by #7782
Labels

Comments

@DMA57361
Copy link

DMA57361 commented Mar 6, 2020

Expected behavior

Code that correctly confirms to the Layout/MultilineMethodCallIndentation cop's default "aligned" enforced style while making use of blocks with Ruby 2.7's new numbered parameters feature should not raise an offense.

Actual behavior

Lines that follow the numbered parameter block are reported as being indented incorrectly.

Steps to reproduce the problem

Given the following example.rb file:

File.read('data.yml')
    .then { |file| YAML.safe_load file } # normal block param
    .transform_values(&:downcase)
    .freeze

File.read('data.yml')
    .then { YAML.safe_load _1 } # numbered param
    .transform_values(&:downcase)
    .freeze

Running rubocop cop gives the following results:

$ rubocop example.rb --only Layout/MultilineMethodCallIndentation
Inspecting 1 file
C

Offenses:

example.rb:8:5: C: Layout/MultilineMethodCallIndentation: Use 2 (not 4) spaces for indenting an expression spanning multiple lines.
    .transform_values(&:downcase)
    ^^^^^^^^^^^^^^^^^
example.rb:9:5: C: Layout/MultilineMethodCallIndentation: Use 2 (not 4) spaces for indenting an expression spanning multiple lines.
    .freeze
    ^^^^^^^

1 file inspected, 2 offenses detected

Note how the first version of the code in the file (using normal block params) is considered correct while the second version (using Ruby 2.7 numbered params) is considered incorrect.

RuboCop version

$ bundle exec rubocop -V
0.80.1 (using Parser 2.7.0.4, running on ruby 2.7.0 x86_64-linux)
@koic koic added the bug label Mar 7, 2020
koic added a commit to koic/rubocop that referenced this issue Mar 7, 2020
…lIndentation`

Fixes rubocop#7779.

This PR fixes a false positive for `Style/MultilineMethodCallIndentation`
when using Ruby 2.7's block parameter.
koic added a commit to koic/rubocop that referenced this issue Mar 7, 2020
…lIndentation`

Fixes rubocop#7779.

This PR fixes a false positive for `Style/MultilineMethodCallIndentation`
when using Ruby 2.7's numbered parameter.
bbatsov added a commit that referenced this issue Mar 7, 2020
…ation` (#7782)

Fixes #7779.

This PR fixes a false positive for `Style/MultilineMethodCallIndentation`
when using Ruby 2.7's numbered parameter.

Co-authored-by: Bozhidar Batsov <bozhidar@batsov.com>
ty-porter pushed a commit to ty-porter/rubocop that referenced this issue Mar 21, 2020
…lIndentation` (rubocop#7782)

Fixes rubocop#7779.

This PR fixes a false positive for `Style/MultilineMethodCallIndentation`
when using Ruby 2.7's numbered parameter.

Co-authored-by: Bozhidar Batsov <bozhidar@batsov.com>
Neodelf pushed a commit to Neodelf/rubocop that referenced this issue Apr 28, 2020
…lIndentation` (rubocop#7782)

Fixes rubocop#7779.

This PR fixes a false positive for `Style/MultilineMethodCallIndentation`
when using Ruby 2.7's numbered parameter.

Co-authored-by: Bozhidar Batsov <bozhidar@batsov.com>
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