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

[FIX #4189] Lint/AmbiguousBlockAssociation cites unambiguous lambda p… #4237

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

## master (unreleased)

### Bug fixes
* [#4237](https://github.com/bbatsov/rubocop/pull/4237): Fix false positive in `Lint/AmbiguousBlockAssociation` cop for lambdas. ([@smakagon][])

## 0.48.1 (2017-04-03)

### Changes
Expand Down
2 changes: 1 addition & 1 deletion lib/rubocop/cop/lint/ambiguous_block_association.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class AmbiguousBlockAssociation < Cop

def on_send(node)
return if node.parenthesized? || allowed_method?(node)
return if lambda_argument?(node.first_argument)
return if lambda_argument?(node.last_argument)

return unless method_with_block?(node.last_argument)
last_param = node.last_argument.children.first
Expand Down
3 changes: 2 additions & 1 deletion spec/rubocop/cop/lint/ambiguous_block_association_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@
it_behaves_like 'accepts', 'Hash[some_method(a) { |el| el }]'
it_behaves_like 'accepts', 'foo = lambda do |diagnostic|;end'
it_behaves_like 'accepts', 'Proc.new { puts "proc" }'
it_behaves_like('accepts', 'expect { order.save }.to(change { orders.size })')
it_behaves_like 'accepts', 'expect { order.save }.to(change { orders.size })'
it_behaves_like 'accepts', 'scope :active, -> { where(status: "active") }'
it_behaves_like(
'accepts',
'assert_equal posts.find { |p| p.title == "Foo" }, results.first'
Expand Down