Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Rubocop reports an error on multiline lambdas in scopes #1520
This issue has been originally reported in #1482 but has been closed by mistake as it's still reproducible in v. 0.28.0
Hey, I have a scope defined:
scope :some_scope, ->(param) do ... end
Rubocop claims on
But when I change it to:
scope :some_scope, lambda do |param| ... end
It claims on
So what is the correct syntax in this case?
Hi @k-rudy, I've been there too...
The syntax RuboCop expects you to write is:
What I don't know is whether there's an option to allow the first syntax you used (which I like better than RuboCop's default).
Yep, the problem is that the
It's just not equivalent...
@Rajasree Whether the lambda takes a parameter or not, the alternatives are the same. I would suggest adding a local variable:
f = lambda do |param| ... end scope :some_scope, f
Maybe this looks unidiomatic, and then there's the other alternative, which I thinks is ugly:
scope :some_scope, (lambda do |param| ... end)