Skip to content

Commit

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

This PR fixes an error for `Layout/MultilineMethodCallIndentation`
when usingarithmetic operation with block inside a grouped expression.
  • Loading branch information
koic committed Oct 11, 2023
1 parent 84840b8 commit a4a505d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* [#12265](https://github.com/rubocop/rubocop/issues/12265): Fix an error for `Layout/MultilineMethodCallIndentation` when usingarithmetic operation with block inside a grouped expression. ([@koic][])
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ def semantic_alignment_base(node, rhs)
return unless rhs.source.start_with?('.', '&.')

node = semantic_alignment_node(node)
return unless node&.loc&.selector
return unless node&.loc&.selector && node.loc.dot

node.loc.dot.join(node.loc.selector)
end
Expand Down
10 changes: 10 additions & 0 deletions spec/rubocop/cop/layout/multiline_method_call_indentation_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,16 @@
RUBY
end

it 'accepts arithmetic operation with block inside a grouped expression' do
expect_no_offenses(<<~RUBY)
(
a * b do
end
)
.c
RUBY
end

it 'accepts an expression where the first method spans multiple lines' do
expect_no_offenses(<<~RUBY)
subject.each do |item|
Expand Down

0 comments on commit a4a505d

Please sign in to comment.