From e9e0482703fd5f729d96d6fad8f6273567b252d5 Mon Sep 17 00:00:00 2001 From: Koichi ITO Date: Sun, 8 Mar 2020 03:09:34 +0900 Subject: [PATCH] [Fix #7779] Fix a false positive for `Style/MultilineMethodCallIndentation` (#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 --- CHANGELOG.md | 1 + lib/rubocop/ast/node.rb | 2 +- .../layout/multiline_method_call_indentation_spec.rb | 11 +++++++++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c958e4758be..8bf6d801908 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ ### 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][]) * [#7733](https://github.com/rubocop-hq/rubocop/issues/7733): Fix rubocop-junit-formatter imcompatibility XML for JUnit formatter. ([@koic][]) ## 0.80.1 (2020-02-29) 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)