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

[Fix #6974] Make Layout/FirstMethodArgumentLineBreak aware of calling using super #6976

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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