-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
safe-auto-correct breaks the code #10563
Comments
Can you specify which cop caused a problem and what the problem is? |
problem is that var code deleted by {|a| [a.disease_measure_name, a.diet]}.group_by{|c| c[1].name} #.map {|d| d[1]}.compact I think the cop is something related to indentation. Thought to publish it here. It might be a good case scenario to improve even more this awesome gem. |
It seems to be caused by it 'registers an offense when there is a comment after the closing brace and block body is not empty' do
expect_offense(<<~RUBY)
baz.map { |x|
^ Avoid using `{...}` for multi-line blocks.
foo(x) }.map { |x| x.quux } # comment
RUBY
expect_correction(<<~RUBY)
# comment
baz.map do |x|
foo(x) end.map { |x| x.quux }
RUBY
end The case returns result: Diff:
@@ -1,6 +1,4 @@
# comment
baz.map do |x|
-foo(x) end.map { |x| x.quux }
+foo(x) end.map |
…block on moving comment if methods with block are chained
…hen-style-block-delimiters-treats-comment [Fix #10563] Fix `Style/BlockDelimiters` unexpectedly deletes block
Applied
rubocop -a
and it broken code:Before:
After:
The text was updated successfully, but these errors were encountered: