Skip to content

Commit

Permalink
Fix a false positive for Layout/ClosingParenthesisIndentation
Browse files Browse the repository at this point in the history
This PR fixes a false positive for `Layout/ClosingParenthesisIndentation`
when using keyword arguemnts.
  • Loading branch information
koic authored and bbatsov committed Jun 26, 2021
1 parent 8ff511c commit 89463f6
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
@@ -0,0 +1 @@
* [#9888](https://github.com/rubocop/rubocop/pull/9888): Fix a false positive for `Layout/ClosingParenthesisIndentation` when using keyword arguemnts. ([@koic][])
8 changes: 7 additions & 1 deletion lib/rubocop/cop/layout/closing_parenthesis_indentation.rb
Expand Up @@ -155,7 +155,13 @@ def expected_column(left_paren, elements)
end

def all_elements_aligned?(elements)
elements.map { |e| e.loc.column }.uniq.count == 1
elements.flat_map do |e|
if e.hash_type?
e.each_pair.map { |pair| pair.loc.column }
else
e.loc.column
end
end.uniq.count == 1
end

def first_argument_line(elements)
Expand Down
Expand Up @@ -48,6 +48,15 @@
RUBY
end

it 'does not register an offense when using keyword arguments' do
expect_no_offenses(<<~RUBY)
some_method(x: 1,
y: 2,
z: 3
)
RUBY
end

it 'accepts a correctly indented )' do
expect_no_offenses(<<~RUBY)
some_method(a,
Expand Down

0 comments on commit 89463f6

Please sign in to comment.