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 using rubocop --auto-correct --safe test.rb on this file, the whole comment after the block is dropped.
FactoryBot.definedofactory:foodo# This line:# raw_article_id { instance.article_id } # ATTENTION: foobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobar# becomes this (not the missing comment!):# raw_article_id do# instance.article_id# endraw_article_id{instance.article_id}# ATTENTION: foobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarendend
Expected behavior
The comment should be kept - no matter where
Actual behavior
see the ruby code above (shouldn't matter that it is from factory bot I guess)
$ rubocop --auto-correct --safe --debug test.rb
For /media/sicrepos/sic_dev/github: Default configuration from /home/sweethome/.rvm/gems/ruby-3.0.1/gems/rubocop-1.18.1/config/default.yml
Inspecting 1 file
Scanning /media/sicrepos/sic_dev/github/test.rb
Loading cache from /home/sweethome/.cache/rubocop_cache/a406249fe5b009545c87f1399ff9a9d947889e6d/ecccc5a26c57637834a87a0f8112dae74e190d88/30ea5a4ea576d75ab9538a6292664d1c8e9d4771
C
Offenses:
test.rb:1:1: C: [Correctable] Style/FrozenStringLiteralComment: Missing frozen string literal comment.
FactoryBot.define do
^
test.rb:4:121: C: Layout/LineLength: Line is too long. [136/120]
# raw_article_id { instance.article_id } # ATTENTION: foobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobar
^^^^^^^^^^^^^^^^
test.rb:11:20: C: [Corrected] Style/BlockDelimiters: Avoid using {...} for multi-line blocks.
raw_article_id {
^
test.rb:11:121: C: [Corrected] Layout/LineLength: Line is too long. [134/120]
raw_article_id { instance.article_id } # ATTENTION: foobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobar
^^^^^^^^^^^^^^
test.rb:12:1: C: [Corrected] Layout/IndentationWidth: Use 2 (not 1) spaces for indentation.
instance.article_id
^
test.rb:12:3: C: [Corrected] Layout/IndentationWidth: Use 2 (not -2) spaces for indentation.
instance.article_id
^^
test.rb:12:22: C: [Corrected] Layout/BlockEndNewline: Expression at 12, 22 should be on its own line.
instance.article_id } # ATTENTION: foobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobar
^
test.rb:13:1: C: [Corrected] Layout/BlockAlignment: } at 13, 0 is not aligned with raw_article_id { at 11, 4.
} # ATTENTION: foobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobar
^
test.rb:13:13: C: [Corrected] Style/CommentedKeyword: Do not place comments on the same line as the end keyword.
end # ATTENTION: foobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobar
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1 file inspected, 9 offenses detected, 7 offenses corrected, 1 more offense can be corrected with `rubocop -A`
Finished in 0.17514862899997752 seconds
Steps to reproduce the problem
Take the ruby code above in a test.rb and use the command line as mentioned.
…miters`
Fixesrubocop#9902
This PR fixes an incorrect auto-correct for `Style/BlockDelimiters`
when there is a comment after the closing brace.
It prevents `Style/CommentedKeyword` from removing source code
comment after `end` keyword.
Fixes#9902
This PR fixes an incorrect auto-correct for `Style/BlockDelimiters`
when there is a comment after the closing brace.
It prevents `Style/CommentedKeyword` from removing source code
comment after `end` keyword.
When using
rubocop --auto-correct --safe test.rb
on this file, the whole comment after the block is dropped.Expected behavior
The comment should be kept - no matter where
Actual behavior
see the ruby code above (shouldn't matter that it is from factory bot I guess)
Steps to reproduce the problem
Take the ruby code above in a test.rb and use the command line as mentioned.
RuboCop version
Cheers and thanks for all your work!
The text was updated successfully, but these errors were encountered: