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

Preformance/RedundantEqualityComparisonBlock is incorrect #225

Closed
twalpole opened this issue Mar 14, 2021 · 1 comment · Fixed by #226
Closed

Preformance/RedundantEqualityComparisonBlock is incorrect #225

twalpole opened this issue Mar 14, 2021 · 1 comment · Fixed by #226
Assignees
Labels
bug Something isn't working

Comments

@twalpole
Copy link

For code like

items.any? { |item| item === pattern }

the cop is reporting/autofixing with

items.any?(pattern)

This is incorrect since any? with a pattern is equivalent to

items.any? { |item| pattern === item }

https://ruby-doc.org/core-2.5.1/Enumerable.html#method-i-any-3F

@marcandre
Copy link
Contributor

Indeed, we should assume that the order with === is very important, contrary to ==

@marcandre marcandre added the bug Something isn't working label Mar 15, 2021
koic added a commit to koic/rubocop-performance that referenced this issue Mar 15, 2021
…mparisonBlock`

Fixes rubocop#225

This PR fixes a false positive for `Style/RedundantEqualityComparisonBlock`
when using `any?` with `===` comparison block and block argument is not used
as a receiver for `===`.
koic added a commit to koic/rubocop-performance that referenced this issue Mar 16, 2021
…mparisonBlock`

Fixes rubocop#225

This PR fixes a false positive for `Style/RedundantEqualityComparisonBlock`
when using `any?` with `===` comparison block and block argument is not used
as a receiver for `===`.
koic added a commit to koic/rubocop-performance that referenced this issue Mar 17, 2021
…mparisonBlock`

Fixes rubocop#225

This PR fixes a false positive for `Style/RedundantEqualityComparisonBlock`
when using `any?` with `===` comparison block and block argument is not used
as a receiver for `===`.
@koic koic closed this as completed in #226 Mar 20, 2021
koic added a commit that referenced this issue Mar 20, 2021
…equality_comparison

[Fix #225] Fix a false positive for `Style/RedundantEqualityComparisonBlock`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants