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
FactoryBot.definedofactory:somethingdotextdo<<~EOFLong here doc with several empty linesblablaEOFendendend
rubocop -a output and result:
FactoryBot.definedofactory:somethingdotextdo<<~EOF Long here doc with several empty lines#{' '} bla#{' '} bla EOFendendend
Inspecting 1 file
C
Offenses:
spec/factories/code_reviews.rb:5:12: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected.
text do
^
spec/factories/code_reviews.rb:5:13: C: [Corrected] Layout/MultilineBlockLayout: Block body expression is on the same line as the block start.
text do <<~EOF
^^^^^^
spec/factories/code_reviews.rb:6:1: C: [Corrected] Layout/HeredocIndentation: Use 2 spaces for indentation in a heredoc.
Long here doc with several empty lines ...
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/factories/code_reviews.rb:7:1: C: [Corrected] Layout/HeredocIndentation: Use 2 spaces for indentation in a heredoc.
Long here doc with several empty lines ...
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/factories/code_reviews.rb:8:1: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected.
spec/factories/code_reviews.rb:10:1: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected.
spec/factories/code_reviews.rb:11:1: C: [Corrected] Layout/ClosingHeredocIndentation: EOF is not aligned with text do <<~EOF.
EOF
^^^
spec/factories/code_reviews.rb:12:1: C: [Corrected] Layout/ClosingHeredocIndentation: EOF is not aligned with <<~EOF.
EOF
^^^^^^^
1 file inspected, 8 offenses detected, 8 offenses corrected
Note that the indentation of non-empty lines is actually incorrect.
I can then replace #{' '} with an empty line and run again to get a much more reasonable result:
FactoryBot.definedofactory:somethingdotextdo<<~EOF Long here doc with several empty lines bla bla EOFendendend
Inspecting 1 file
C
Offenses:
spec/factories/code_reviews.rb:7:1: C: [Corrected] Layout/HeredocIndentation: Use 2 spaces for indentation in a heredoc.
Long here doc with several empty lines ...
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1 file inspected, 1 offense detected, 1 offense corrected
The 2 are indentical because <<~ vs <<- but the latter is definitely more readable.
Expected behavior
I would like the second result automatically.
RuboCop version
Include the output of rubocop -V or bundle exec rubocop -V if using Bundler.
If you see extension cop versions (e.g. rubocop-performance, rubocop-rspec, and others)
output by rubocop -V, include them as well. Here's an example:
What happens here is that Layout/HeredocIndentation, when it changes the indentation of the lines in the heredoc, also adds spaces on the empty lines. This is unnecessary, but it doesn't change the semantics of the code. The resulting heredoc string has the same value as before.
Then Layout/TrailingWhitespace comes in and inserts the string interpolation markers on the whitespace lines, and this is a bug. It changes the string values.
Actual behavior
rubocop -a
output and result:Note that the indentation of non-empty lines is actually incorrect.
I can then replace
#{' '}
with an empty line and run again to get a much more reasonable result:The 2 are indentical because
<<~
vs<<-
but the latter is definitely more readable.Expected behavior
I would like the second result automatically.
RuboCop version
Include the output of
rubocop -V
orbundle exec rubocop -V
if using Bundler.If you see extension cop versions (e.g.
rubocop-performance
,rubocop-rspec
, and others)output by
rubocop -V
, include them as well. Here's an example:The text was updated successfully, but these errors were encountered: