From d8bdede1eff121594466c568bc32373b7839d35c Mon Sep 17 00:00:00 2001 From: Koichi ITO Date: Sun, 8 Mar 2020 00:53:36 +0900 Subject: [PATCH] [Fix #7779] Fix a false positive for `Style/MultilineMethodCallIndentation` Fixes #7779. This PR fixes a false positive for `Style/MultilineMethodCallIndentation` when using Ruby 2.7's numbered parameter. --- CHANGELOG.md | 4 ++++ lib/rubocop/ast/node.rb | 2 +- .../layout/multiline_method_call_indentation_spec.rb | 11 +++++++++++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4d96d89895f..e45ec2a0cac 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ * [#7654](https://github.com/rubocop-hq/rubocop/issues/7654): Support `with_fixed_indentation` option for `Layout/ArrayAlignment` cop. ([@nikitasakov][]) +### Bug fixes + +* [#7779](https://github.com/rubocop-hq/rubocop/issues/7779): Fix a false positive for `Style/MultilineMethodCallIndentation` when using Ruby 2.7's numbered parameter. ([@koic][]) + ## 0.80.1 (2020-02-29) ### Bug fixes diff --git a/lib/rubocop/ast/node.rb b/lib/rubocop/ast/node.rb index 65bf9a4935d..b4b9a5e9d5e 100644 --- a/lib/rubocop/ast/node.rb +++ b/lib/rubocop/ast/node.rb @@ -291,7 +291,7 @@ def source_length ## Destructuring def_node_matcher :receiver, <<~PATTERN - {(send $_ ...) (block (send $_ ...) ...)} + {(send $_ ...) ({block numblock} (send $_ ...) ...)} PATTERN def_node_matcher :str_content, '(str $_)' diff --git a/spec/rubocop/cop/layout/multiline_method_call_indentation_spec.rb b/spec/rubocop/cop/layout/multiline_method_call_indentation_spec.rb index 659619d1d6b..500dbc701f0 100644 --- a/spec/rubocop/cop/layout/multiline_method_call_indentation_spec.rb +++ b/spec/rubocop/cop/layout/multiline_method_call_indentation_spec.rb @@ -248,6 +248,17 @@ def foo RUBY end + context '>= Ruby 2.7', :ruby27 do + it 'accepts methods being aligned with method that is an argument' \ + 'when using numbered parameter' do + expect_no_offenses(<<~RUBY) + File.read('data.yml') + .then { YAML.safe_load _1 } + .transform_values(&:downcase) + RUBY + end + end + it 'accepts methods being aligned with method that is an argument in ' \ 'assignment' do expect_no_offenses(<<~RUBY)