Skip to content

Chained #map methods throw an error. #374

@wawer77

Description

@wawer77

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

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