Skip to content

Commit

Permalink
Merge pull request #7828 from tejasbubane/fix-7825
Browse files Browse the repository at this point in the history
[Fix #7825] Fix crash for `Layout/MultilineMethodCallIndentation`
  • Loading branch information
koic committed Mar 29, 2020
2 parents 5d47450 + 06309e1 commit fac6d99
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
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

0 comments on commit fac6d99

Please sign in to comment.