From 87a4e3785eda90b4bc55381a3a092201d694aa3e Mon Sep 17 00:00:00 2001 From: Koichi ITO Date: Mon, 3 Aug 2020 20:24:48 +0900 Subject: [PATCH] [Fix #8444] Fix an error for `Layout/FirstMethodArgumentLineBreak Fixes #8444. This PR fixes an error for `Layout/FirstMethodArgumentLineBreak` when using kwargs in `super` --- CHANGELOG.md | 1 + lib/rubocop/cop/layout/first_method_argument_line_break.rb | 2 +- .../cop/layout/first_method_argument_line_break_spec.rb | 4 ++++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 736d05fffee..425e5d131c8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -39,6 +39,7 @@ * [#8283](https://github.com/rubocop-hq/rubocop/issues/8283): Fix line length calculation for `Style/IfUnlessModifier` to correctly take into account a comment on the first line when considering conversation to a single-line form. ([@dsavochkin][]) * [#8226](https://github.com/rubocop-hq/rubocop/issues/8226): Fix `Style/IfUnlessModifier` to add parentheses when converting if-end condition inside an array or a hash to a single-line form. ([@dsavochkin][]) * [#8443](https://github.com/rubocop-hq/rubocop/pull/8443): Fix an incorrect auto-correct for `Style/StructInheritance` when there is a comment before class declaration. ([@koic][]) +* [#8444](https://github.com/rubocop-hq/rubocop/issues/8444): Fix an error for `Layout/FirstMethodArgumentLineBreak` when using kwargs in `super`. ([@koic][]) ### Changes diff --git a/lib/rubocop/cop/layout/first_method_argument_line_break.rb b/lib/rubocop/cop/layout/first_method_argument_line_break.rb index c6b83b92680..25d6661cf43 100644 --- a/lib/rubocop/cop/layout/first_method_argument_line_break.rb +++ b/lib/rubocop/cop/layout/first_method_argument_line_break.rb @@ -27,7 +27,7 @@ class FirstMethodArgumentLineBreak < Cop 'multi-line method argument list.' def on_send(node) - args = node.arguments + args = node.arguments.dup # If there is a trailing hash arg without explicit braces, like this: # diff --git a/spec/rubocop/cop/layout/first_method_argument_line_break_spec.rb b/spec/rubocop/cop/layout/first_method_argument_line_break_spec.rb index d26ce9e8cc8..0adc2cec5fa 100644 --- a/spec/rubocop/cop/layout/first_method_argument_line_break_spec.rb +++ b/spec/rubocop/cop/layout/first_method_argument_line_break_spec.rb @@ -80,6 +80,10 @@ expect_no_offenses('foo(bar, baz, bing)') end + it 'ignores kwargs listed on a single line when the arguments are used in `super`' do + expect_no_offenses('super(foo: 1, bar: 2)') + end + it 'ignores arguments without parens' do expect_no_offenses(<<~RUBY) foo bar,