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

Lint/AmbiguousBlockAssociation - a false positive case for proc #10566

Closed
deepj opened this issue Apr 22, 2022 · 0 comments · Fixed by #10567
Closed

Lint/AmbiguousBlockAssociation - a false positive case for proc #10566

deepj opened this issue Apr 22, 2022 · 0 comments · Fixed by #10567
Labels

Comments

@deepj
Copy link
Contributor

deepj commented Apr 22, 2022

Expected behavior

The following code is used in a Capistrano script.

ask :branch, proc { `git rev-parse --abbrev-ref HEAD`.chomp }

The code doesn't violate Lint/AmbiguousBlockAssociation cop

Actual behavior

W: Lint/AmbiguousBlockAssociation: Parenthesize the param proc { git rev-parse --abbrev-ref HEAD.chomp } to make sure that the block will be associated with the proc method call.

When I use lambda or -> instead of proc or Proc.new, this cop is not violated.

One note: ` characters from the block are omitted in the cop's message

Steps to reproduce the problem

Code snippet

ask :branch, proc { `git rev-parse --abbrev-ref HEAD`.chomp }

Run

rubocop --only Lint/AmbiguousBlockAssociation

RuboCop version

$ rubocop -V
1.28.1 (using Parser 3.1.2.0, rubocop-ast 1.17.0, running on ruby 3.1.2 arm64-darwin21)
  - rubocop-performance 1.13.3
  - rubocop-rails 2.14.2
@koic koic added the bug label Apr 22, 2022
koic added a commit to koic/rubocop that referenced this issue Apr 22, 2022
…ociation`

Fixes rubocop#10566.

This PR fixes a falase positive for `Lint/AmbiguousBlockAssociation`
when using proc is used as a last argument.
koic added a commit to koic/rubocop that referenced this issue Apr 22, 2022
…ociation`

Fixes rubocop#10566.

This PR fixes a false positive for `Lint/AmbiguousBlockAssociation`
when using proc is used as a last argument.
koic added a commit that referenced this issue Apr 23, 2022
…iguous_block_association

[Fix #10566] Fix a falase positive for `Lint/AmbiguousBlockAssociation`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants