Skip to content

Commit

Permalink
Merge pull request #12266 from koic/fix_an_error_for_layout_multiline…
Browse files Browse the repository at this point in the history
…_method_call_indentation

[Fix #12265] Fix an error for `Layout/MultilineMethodCallIndentation`
  • Loading branch information
koic committed Oct 11, 2023
2 parents 84840b8 + a4a505d commit 42898bc
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 42898bc

Please sign in to comment.