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
[Fix #7534] Fix an incorrect autocorrect for Layout/SpaceBeforeBlockBraces
#7535
[Fix #7534] Fix an incorrect autocorrect for Layout/SpaceBeforeBlockBraces
#7535
Conversation
f7852cf
to
9709601
Compare
EnforcedStyle: no_space | ||
YAML | ||
|
||
expect(cli.run(%w[--auto-correct])).to eq(0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please don't let this example depend on other cops than --only Style/BlockDelimiters,Layout/SpaceBeforeBlockBraces
. This is to prevent unnecessary work in the future if any of the unrelated cops changes. I remember 8d071f0 all to well …
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the review. I updated it.
9709601
to
e12736e
Compare
…reBlockBraces` Fixes rubocop#7534. Fix an incorrect autocorrect for `Style/BlockDelimiters` cop and `Layout/SpaceBeforeBlockBraces` cop with `EnforcedStyle: no_space` when using multiline braces.
e12736e
to
e61357e
Compare
@@ -1653,6 +1653,32 @@ def self.some_method(foo, bar: 1) | |||
RUBY | |||
end | |||
|
|||
it 'corrects Style/BlockDelimiters offenses when specifing' \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
small typo here (if you care): "specifying" instead of "specifing"
Thanks so much for posting the bugfix in such a timely manner! I am amazed at how quickly you did so! You're awesome!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This typo fixed by e97eb5c. Thanks!
@@ -110,6 +118,15 @@ def style_for_empty_braces | |||
end | |||
end | |||
|
|||
def conflict_with_block_delimiters? | |||
block_delimiters_style == 'line_count_based' && | |||
style == :no_space && node.multiline? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@koic
With rubocop-0.78.0 I got the below error. Do you have any idea?
An error occurred while Layout/SpaceBeforeBlockBraces cop was inspecting /webapp/spec/my_spec.rb:697:6.
undefined local variable or method `node' for #<RuboCop::Cop::Layout::SpaceBeforeBlockBraces:0x0000560a675e42d8>
/usr/local/bundle/gems/rubocop-0.78.0/lib/rubocop/cop/layout/space_before_block_braces.rb:123:in `conflict_with_block_delimiters?'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@johnny-miyake Thanks for your feedback. Can you open the issue with the reproduction code?
https://github.com/rubocop-hq/rubocop/issues
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixes #7534.
Fix an incorrect autocorrect for
Style/BlockDelimiters
cop andLayout/SpaceBeforeBlockBraces
cop withEnforcedStyle: no_space
when using multiline braces.Before submitting the PR make sure the following are checked:
[Fix #issue-number]
(if the related issue exists).master
(if not - rebase it).bundle exec rake default
. It executes all tests and RuboCop for itself, and generates the documentation.