Skip to content

Commit

Permalink
[Fix rubocop#9140] Fix an error for Layout/EmptyLinesAroundArguments
Browse files Browse the repository at this point in the history
Fixes rubocop#9140.

This PR fixes an error for `Layout/EmptyLinesAroundArguments`
when multiline style argument for method call without selector.
  • Loading branch information
koic authored and bbatsov committed Dec 2, 2020
1 parent c0f6b9d commit 0849d36
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* [#9140](https://github.com/rubocop-hq/rubocop/issues/9140): Fix an error for `Layout/EmptyLinesAroundArguments` when multiline style argument for method call without selector. ([@koic][])
2 changes: 1 addition & 1 deletion lib/rubocop/cop/layout/empty_lines_around_arguments.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def on_send(node)
private

def receiver_and_method_call_on_different_lines?(node)
node.receiver && node.receiver.loc.last_line != node.loc.selector.line
node.receiver && node.receiver.loc.last_line != node.loc.selector&.line
end

def empty_lines(node)
Expand Down
8 changes: 8 additions & 0 deletions spec/rubocop/cop/layout/empty_lines_around_arguments_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,14 @@ def anything; end
RUBY
end

it 'accepts multiline style argument for method call without selector' do
expect_no_offenses(<<~RUBY)
foo.(
arg
)
RUBY
end

context 'with one argument' do
it 'ignores empty lines inside of method arguments' do
expect_no_offenses(<<~RUBY)
Expand Down

0 comments on commit 0849d36

Please sign in to comment.