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 an error for Layout/HeredocArgumentClosingParenthesis #11579

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
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* [#11579](https://github.com/rubocop/rubocop/pull/11579): Fix an error for `Layout/HeredocArgumentClosingParenthesis` when heredoc is a method argument in a parenthesized block argument. ([@koic][])
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ def incorrect_parenthesis_removal_end(node)
end

def exist_argument_between_heredoc_end_and_closing_parentheses?(node)
return true unless node.loc.end
return false unless (heredoc_end = find_most_bottom_of_heredoc_end(node.arguments))

heredoc_end < node.loc.end.begin_pos &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,16 @@
RUBY
end

it 'accepts when heredoc is a method argument in a parenthesized block argument' do
expect_no_offenses(<<~RUBY)
foo(bar do
baz <<~EOS
text
EOS
end)
RUBY
end

it 'accepts correct case with other param after' do
expect_no_offenses(<<~RUBY)
foo(<<-SQL, 123)
Expand Down