Skip to content
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
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* [#452](https://github.com/rubocop/rubocop-performance/pull/452): Fix an error for `Performance/RedundantEqualityComparisonBlock` when the block is empty. ([@earlopain][])
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def on_block(node)
return unless one_block_argument?(node.arguments)

block_argument = node.first_argument
block_body = node.body
return unless (block_body = node.body)
return unless use_equality_comparison_block?(block_body)
return if same_block_argument_and_is_a_argument?(block_body, block_argument)
return unless (new_argument = new_argument(block_argument, block_body))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,4 +181,16 @@
items.any? { |item| do_something[0..item] == item }
RUBY
end

it 'does not register an offense when the block is empty' do
expect_no_offenses(<<~RUBY)
items.any? { |item| }
RUBY
end

it 'does not register an offense when the block takes no argument' do
expect_no_offenses(<<~RUBY)
items.any? { }
RUBY
end
end