Skip to content

Performance/RedundantEqualityComparisonBlock doesn't consider multidimensional arrays #214

@davidenglishmusic

Description

@davidenglishmusic

The cop assumes the input is a single dimensional array.


Expected behavior

It should not flag the infraction with an incorrect suggestion.

Actual behavior

It flags the infraction with an incorrect suggestion.

Steps to reproduce the problem

Run bundle exec rubocop -a on the following code:

[%w[lettuce vegetable], %w[orange fruit], %w[asparagus vegetable]].any? { |name, _type| name == 'orange' }

C: [Correctable] Performance/RedundantEqualityComparisonBlock: Use any?('orange') instead of block.

RuboCop version

1.10.0 (using Parser 3.0.0.0, rubocop-ast 1.4.1, running on ruby 2.6.6 x86_64-darwin20)
  - rubocop-performance 1.10.0
  - rubocop-rails 2.9.1
  - rubocop-rspec 2.2.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions