rubocop / rubocop-performance

An extension of RuboCop focused on code performance checks.
https://docs.rubocop.org/rubocop-performance
MIT License
684 stars 81 forks source link

Chained #map methods throw an error. #374

Closed wawer77 closed 1 year ago

wawer77 commented 1 year ago

When checking map(&:method_x).map(&:method_y) line being a definition of another method, an error is reported:

1 error occurred:
An error occurred while Performance/MapMethodChain cop was inspecting (...)

Expected behavior

Inform about the offence / correct the offence.

Actual behavior

I get following message after running rubocop -d:

(x) files inspected, no offenses detected

1 error occurred:
An error occurred while Performance/MapMethodChain cop was inspecting (x)

Steps to reproduce the problem

Define a method with 2 map methods chained, like:

def method
  map(&:method_x).map(&:method_y)
end

RuboCop version

1.56.3 (using Parser 3.2.2.3, rubocop-ast 1.29.0, running on ruby 3.2.2) [arm64-darwin22]
  - rubocop-performance 1.19.1
  - rubocop-rails 2.21.1