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/SpaceBeforeBlockBraces doesn't run when Style/BlockDelimiters is enabled #3374

Closed
DexterTheDragon opened this issue Aug 5, 2016 · 0 comments

Comments

@DexterTheDragon
Copy link

When using the Style/SpaceBeforeBlockBraces cop if the Style/BlockDelimiters is also enabled then the Style/SpaceBeforeBlockBraces cop is not run. The code (space_before_block_braces.rb#L15-L22) implies that this is intentional saying that if you use braces for a multi-line block then you will get a warning to replace it with do...end in which case the space before the brace doesn't matter. But this is only true when using the Style/BlockDelimiters EnforcedStyle setting of line_count_based, which prohibits mutli-line blocks using braces.

But if you use the EnforcedStyle setting of either semantic or braces_for_chaining, both of which allow multi-line blocks to use braces is some cases, then you expect to get a warning from Style/SpaceBeforeBlockBraces and don't.


Steps to reproduce the problem

test.rb

foo.map{ |a|
  a.bar.to_s
}

test.yml

Style/BlockDelimiters:  
  Enabled: true
  EnforcedStyle: semantic

Style/SpaceBeforeBlockBraces:          
  Enabled: true
$ rubocop --config test.yml --only Style/SpaceBeforeBlockBraces test.rb

Expected behavior

Offenses:

test.rb:1:8: C: Space missing to the left of {.
foo.map{ |a|
       ^

1 file inspected, 1 offense detected

Actual behavior

1 file inspected, no offenses detected

RuboCop version

$ rubocop -V
0.42.0 (using Parser 2.3.1.2, running on ruby 2.3.1 x86_64-linux)
jonas054 added a commit to jonas054/rubocop that referenced this issue Aug 27, 2016
Same in SpaceBeforeBlockBraces. The reason we needed this special
handling seems to be gone now. Auto-correct has become smarter.
Neodelf pushed a commit to Neodelf/rubocop that referenced this issue Oct 15, 2016
…ces (rubocop#3446)

Same in SpaceBeforeBlockBraces. The reason we needed this special
handling seems to be gone now. Auto-correct has become smarter.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant