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

Incorrect handling of multiline blocks in the middle of the method #1676

Closed
andrusha opened this issue Feb 25, 2015 · 1 comment
Closed

Incorrect handling of multiline blocks in the middle of the method #1676

andrusha opened this issue Feb 25, 2015 · 1 comment
Labels

Comments

@andrusha
Copy link

0.29.1 (using Parser 2.2.0.3, running on ruby 2.1.5 x86_64-darwin14.0)
ruby 2.1.5p273 (2014-11-13 revision 48405) [x86_64-darwin14.0]

Happens in Rails 4-style association definition

-  has_many :kittens, -> {
+  has_many :kittens, lambda do
     where(cats: Cat.young.where_values_hash)
-  }, source: :cats, class_name: 'Cat'
+  end, source: :cats, class_name: 'Cat'

Causes SyntaxError:

.../2.1.0/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:247:in `require': ../Projects/catbook/app/models/master.rb:11: syntax error, unexpected ',', expecting keyword_end (SyntaxError)
  end, source: :cats, class_name: 'Cat'
      ^
@jonas054
Copy link
Collaborator

It looks like you have run rubocop --autocorrect to get the above syntax error. Then we have a bug in the Lambda cop that I think can be fixed by using the AutocorrectUnlessChangingAST module.

@bbatsov bbatsov added the bug label Mar 6, 2015
bbatsov added a commit that referenced this issue Mar 19, 2015
[Fix #1676] Disable argument lambda auto-correction in Lambda
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants