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

AmbiguousBlockAssociation False Positive #4227

Closed
ashmaroli opened this issue Apr 1, 2017 · 1 comment · May be fixed by juslee/java-buildpack#1
Closed

AmbiguousBlockAssociation False Positive #4227

ashmaroli opened this issue Apr 1, 2017 · 1 comment · May be fixed by juslee/java-buildpack#1

Comments

@ashmaroli
Copy link

ashmaroli commented Apr 1, 2017

Lint/AmbiguousBlockAssociation cop raises a false alarm against non-dubious block association.

Example Code

assert_equal site.posts.find { |p| p.title == "Foo Bar" }, results.first

Expected behavior

Does not expect Rubocop to flag the code above and even if it did, I expect the message to tell me to parenthesize the param to associate the block with find call.

Actual behavior

W: Lint/AmbiguousBlockAssociation: Parenthesize the param find to make sure that the block will
be associated with the assert_equal method call.
        assert_equal site.posts.find { |p| p.title == "Foo Bar" }, results.first
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Steps to reproduce the problem

Run rubocop against following:

assert_equal site.posts.find { |p| p.title == "Foo Bar" }, results.first

RuboCop version

Include the output of rubocop -V. Here's an example:

$ rubocop -V
0.48.0 (using Parser 2.4.0.0, running on ruby 2.3.3 i386-mingw32)

(Also tested with latest master branch)
(similar issue: Comment by @stephengroat)

/cc @smakagon

@smakagon
Copy link
Contributor

smakagon commented Apr 1, 2017

@ashmaroli thanks for reporting. Created Pull Request that fixes this case.

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

Successfully merging a pull request may close this issue.

2 participants