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 #7825] Fix crash for Layout/MultilineMethodCallIndentation #7828

Merged
merged 1 commit into from Mar 29, 2020
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 @@ -33,6 +33,7 @@
* [#7806](https://github.com/rubocop-hq/rubocop/pull/7806): Fix an error for `Lint/ErbNewArguments` cop when inspecting `ActionView::Template::Handlers::ERB.new`. ([@koic][])
* [#7814](https://github.com/rubocop-hq/rubocop/issues/7814): Fix a false positive for `Migrate/DepartmentName` cop when inspecting an unexpected disabled comment format. ([@koic][])
* [#7728](https://github.com/rubocop-hq/rubocop/issues/7728): Fix an error for `Style/OneLineConditional` when one of the branches contains a self keyword. ([@koic][])
* [#7825](https://github.com/rubocop-hq/rubocop/issues/7825): Fix crash for `Layout/MultilineMethodCallIndentation` with key access to hash. ([@tejasbubane][])

### Changes

Expand Down
Expand Up @@ -193,7 +193,7 @@ def semantic_alignment_node(node)
node = node.receiver while node.receiver
# ascend to first call which has a dot
node = node.parent
node = node.parent until node.loc.dot
node = node.parent until node.loc.respond_to?(:dot) && node.loc.dot

return if node.loc.dot.line != node.first_line

Expand Down
Expand Up @@ -304,6 +304,15 @@ def foo
RUBY
end

context 'target_ruby_version >= 2.5', :ruby25 do
it 'accepts key access to hash' do
expect_no_offenses(<<~RUBY)
hash[key] { 10 / 0 }
.fmap { |x| x * 3 }
RUBY
end
end

it 'accepts 3 aligned methods' do
expect_no_offenses(<<~RUBY)
a_class.new(severity, location, 'message', 'CopName')
Expand Down