Skip to content

Commit

Permalink
Merge pull request #6976 from koic/first_method_argument_line_break_a…
Browse files Browse the repository at this point in the history
…ware_of_super

[Fix #6974] Make `Layout/FirstMethodArgumentLineBreak` aware of calling using `super`
  • Loading branch information
koic committed Apr 27, 2019
2 parents ac52b1e + 653379e commit 1457ce8
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -9,6 +9,7 @@
* Add new `Layout/HeredocArgumentClosingParenthesis` cop. ([@maxh][])
* [#6895](https://github.com/rubocop-hq/rubocop/pull/6895): Add support for XDG config home for user-config. ([@Mange][], [@tejasbubane][])
* Add initial autocorrection support to `Metrics/LineLength`. ([@maxh][])
* [#6974](https://github.com/rubocop-hq/rubocop/issues/6974): Make `Layout/FirstMethodArgumentLineBreak` aware of calling using `super`. ([@koic][])

### Bug fixes

Expand Down
1 change: 1 addition & 0 deletions lib/rubocop/cop/layout/first_method_argument_line_break.rb
Expand Up @@ -44,6 +44,7 @@ def on_send(node)
check_method_line_break(node, args)
end
alias on_csend on_send
alias on_super on_send

def autocorrect(node)
EmptyLineCorrector.insert_before(node)
Expand Down
14 changes: 14 additions & 0 deletions spec/rubocop/cop/layout/first_method_argument_line_break_spec.rb
Expand Up @@ -25,6 +25,20 @@
RUBY
end

it 'detects the offense when using `super`' do
expect_offense(<<-RUBY.strip_indent)
super(bar,
^^^ Add a line break before the first argument of a multi-line method argument list.
baz)
RUBY

expect_correction(<<-RUBY.strip_indent)
super(
bar,
baz)
RUBY
end

context 'when using safe navigation operator', :ruby23 do
it 'detects the offense' do
expect_offense(<<-RUBY.strip_indent)
Expand Down

0 comments on commit 1457ce8

Please sign in to comment.