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

Allow Curly Brace Block Delimiters for precedence #2627

Closed
CyborgMaster opened this issue Jan 12, 2016 · 3 comments
Closed

Allow Curly Brace Block Delimiters for precedence #2627

CyborgMaster opened this issue Jan 12, 2016 · 3 comments

Comments

@CyborgMaster
Copy link

Based of the following lines in lib/rubocop/cop/style/block_delimiters.rb

          # If there are no parentheses around the arguments, then braces and
          # do-end have different meaning due to how they bind, so we allow
          # either.

it seems that RuboCop should allow either delimiter type ({} or do/end) if operator precedence would make a difference. However the following code:

        cr.stubs client: mock {
          expects(:email_disabled=).with(true)
          expects :save
        }

generates this offence:

C: Style/BlockDelimiters: Avoid using {...} for multi-line blocks.
        cr.stubs client: mock {

If I was to use do/end here, the block would be passed to the stubs method, but I need it to be passed to the mock method, is there something I'm missing or doing wrong here?

@alexdowad
Copy link
Contributor

This is a bug. BlockDelimiters just checks if the last arg is a block node, but in this case it's a hash node, whose last pair contains a block node.

@alexdowad
Copy link
Contributor

Just pushed a fix to my open PR.

@CyborgMaster
Copy link
Author

Awesome! Thanks a ton.

@bbatsov bbatsov closed this as completed in a83b6c4 Mar 9, 2016
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

2 participants