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

Seattle.rb style no longer valid in Ruby 2.4.2 when curly braces are used. #4793

Closed
danielpclark opened this issue Sep 25, 2017 · 1 comment
Closed

Comments

@danielpclark
Copy link

@danielpclark danielpclark commented Sep 25, 2017

As of Ruby 2.4.2 there is a breaking change for any Ruby code that doesn't use parenthesis on a literal before curly braces.

This is no longer allowed:

define_method :some_method_name { "asdf" }

This must now be either:

define_method(:some_method_name) { "asdf" }

or

define_method :some_method_name do "asdf" end

According to Ruby Bug reports https://bugs.ruby-lang.org/issues/13939 and https://bugs.ruby-lang.org/issues/13898 this is the way it has to be.

A brace block has higher precedence and is bound to the previous expression, and a literal cannot be a method call and have a block. - Nobuyoshi Nakada


Expected behavior

When Rubocop finds any literal followed by curly braces suggest wrapping the literal in parenthesis as a parameter or substituting the curly braces for do and end.

Anyone planning to upgrade their project to Ruby 2.4.2 or higher may want to have this pointed out with a cop.

@bbatsov

This comment has been minimized.

Copy link
Collaborator

@bbatsov bbatsov commented Sep 18, 2018

I'm closing this ticket due to no recent activity. Feel free to re-open it if you ever come back to it.

@bbatsov bbatsov closed this Sep 18, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.