You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When an outer method contains a chained method call with heredocs present, the Layout/HeredocArgumentClosingParenthesis cop appears to produce a false positive offense.
Expected behavior
No offenses should be found.
Actual behavior
# Baseline case (works fine)my_outer_method(MyObject.select(Arel.sql("...")).where(Arel.sql("...")))# Raises an offense when Strings are changed to heredocsmy_outer_method(MyObject.select(Arel.sql(<<~SQL.squish)) ... SQL.where(Arel.sql(<<~SQL.squish))) ... SQL###temp.rb:15:36: C: Layout/HeredocArgumentClosingParenthesis: PuttheclosingparenthesisforamethodcallwithaHEREDOCparameteronthesamelineastheHEREDOCopening.(https://rubystyle.guide#heredoc-argument-closing-parentheses).where(Arel.sql(<<~SQL.squish))) ^
Also:
# Also raises the same offense:my_outer_method(->{my_inner_method(<<~SQL.squish) ... SQL})####rcs/temp.rb:7:2: C: Layout/HeredocArgumentClosingParenthesis: PuttheclosingparenthesisforamethodcallwithaHEREDOCparameteronthesamelineastheHEREDOCopening.(https://rubystyle.guide#heredoc-argument-closing-parentheses)})
^
Steps to reproduce the problem
There is no special configuration for this cop. So just run
NOTE: In my testing, the code must contain an outer method as well (which adds in an additional closing paren) to get the offense. E.g. the following does not produce any offenses:
# Works fine due to no outer method (I presume).MyObject.select(Arel.sql(<<~SQL.squish)) ... SQL.where(Arel.sql(<<~SQL.squish)) ... SQL
$ rubocop --only Layout/HeredocArgumentClosingParenthesis temp.rb
temp.rb:7:2: C: Layout/HeredocArgumentClosingParenthesis: Put the closing parenthesis for a method call with a HEREDOC parameter on the same line as the HEREDOC opening. (https://rubystyle.guide#heredoc-argument-closing-parentheses)
})
^
koic
added a commit
to koic/rubocop
that referenced
this issue
Dec 4, 2020
…osingParenthesis`
Fixesrubocop#9161.
This PR fixes a false positive for `Layout/HeredocArgumentClosingParenthesis`
when using subsequence closing parentheses in the same line.
…renthesis`
Fixes#9161.
This PR fixes a false positive for `Layout/HeredocArgumentClosingParenthesis`
when using subsequence closing parentheses in the same line.
When an outer method contains a chained method call with heredocs present, the Layout/HeredocArgumentClosingParenthesis cop appears to produce a false positive offense.
Expected behavior
No offenses should be found.
Actual behavior
Also:
Steps to reproduce the problem
There is no special configuration for this cop. So just run
on
NOTE: In my testing, the code must contain an outer method as well (which adds in an additional closing paren) to get the offense. E.g. the following does not produce any offenses:
UPDATE: This fails as well:
RuboCop version
I've tested this on both 1.4.2 and 1.5.1. Both exhibit the above issue.
The text was updated successfully, but these errors were encountered: