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 a false positive for Layout/ClosingParenthesisIndentation #6351

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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Expand Up @@ -10,6 +10,7 @@

* [#6254](https://github.com/rubocop-hq/rubocop/issues/6254): Fix `Layout/RescueEnsureAlignment` for non-local assignments. ([@marcotc][])
* [#6648](https://github.com/rubocop-hq/rubocop/issues/6648): Fix auto-correction of `Style/EmptyLiteral` when `Hash.new` is passed as the first argument to `super`. ([@rrosenblum][])
* [#6351](https://github.com/rubocop-hq/rubocop/pull/6351): Fix a false positive for `Layout/ClosingParenthesisIndentation` when first argument is multiline. ([@antonzaytsev][])

## 0.63.1 (2019-01-22)

Expand Down Expand Up @@ -3773,6 +3774,7 @@
[@tom-lord]: https://github.com/tom-lord
[@bayandin]: https://github.com/bayandin
[@nadiyaka]: https://github.com/nadiyaka
[@antonzaytsev]: https://github.com/antonzaytsev
[@amatsuda]: https://github.com/amatsuda
[@Intrepidd]: https://github.com/Intrepidd
[@Ruffeng]: https://github.com/Ruffeng
Expand Down
6 changes: 3 additions & 3 deletions lib/rubocop/cop/layout/closing_parenthesis_indentation.rb
Expand Up @@ -147,7 +147,7 @@ def expected_column(left_paren, elements)
left_paren.column
else
source_indent = processed_source
.line_indentation(last_argument_line(elements))
.line_indentation(first_argument_line(elements))
new_indent = source_indent - indentation_width

new_indent < 0 ? 0 : new_indent
Expand All @@ -161,9 +161,9 @@ def all_elements_aligned?(elements)
.count == 1
end

def last_argument_line(elements)
def first_argument_line(elements)
elements
.last
.first
.loc
.first_line
end
Expand Down
21 changes: 21 additions & 0 deletions spec/rubocop/cop/layout/closing_parenthesis_indentation_spec.rb
Expand Up @@ -500,6 +500,27 @@ def some_method()
end
end

context 'method call with first multiline arg on new line' do
it 'accepts ) on the same level as ( with args on same line' do
expect_no_offenses(<<-RUBY.strip_indent)
where(
"multiline
condition", second_arg
)
RUBY
end

it 'accepts ) on the same level as ( with second arg on new line' do
expect_no_offenses(<<-RUBY.strip_indent)
where(
"multiline
condition",
second_arg
)
RUBY
end
end

it 'accepts begin nodes that are not grouped expressions' do
expect_no_offenses(<<-RUBY.strip_indent)
def a
Expand Down