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

Style/BlockDelimiters auto-correct removes code after the closing brace if there is any inline comment following #10033

Closed
iv-nn opened this issue Aug 24, 2021 · 1 comment · Fixed by #10035
Labels

Comments

@iv-nn
Copy link

iv-nn commented Aug 24, 2021

Any code between the closing brace and the inline comment gets removed.


Expected behavior

No code should be removed.

result = # somecomment
  something.select do |a|
    a == 1
  end.first

Actual behavior

Running auto-correct on the following code:

result = something.select { |a|
  a == 1 }.first # somecomment

result in the .first being removed.

result = # somecomment
  something.select do |a|
    a == 1
  end

Steps to reproduce the problem

result = something.select { |a|
  a == 1 }.first # somecomment
$ rubocop --only Style/BlockDelimiters --auto-correct file.rb
result = # somecomment
something.select do |a|
  a == 1 end

RuboCop version

$ rubocop -V
1.19.0 (using Parser 3.0.2.0, rubocop-ast 1.10.0, running on ruby 2.7.4 x86_64-linux)
@koic koic added the bug label Aug 24, 2021
koic added a commit to koic/rubocop that referenced this issue Aug 24, 2021
…imiters`

Fixes rubocop#10033.

This PR fixes an incorrect auto-correct for `Style/BlockDelimiters`
when there is a comment after the closing brace and using method chain.
bbatsov pushed a commit that referenced this issue Aug 24, 2021
Fixes #10033.

This PR fixes an incorrect auto-correct for `Style/BlockDelimiters`
when there is a comment after the closing brace and using method chain.
@iv-nn
Copy link
Author

iv-nn commented Aug 24, 2021

This is the second issue I report here and I have to say I'm very impressed and pleased by how fast and smoothly both were fixed.

Thanks a lot for all your hard work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants