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

Chained #map methods throw an error. #374

Closed
wawer77 opened this issue Sep 27, 2023 · 0 comments · Fixed by #375
Closed

Chained #map methods throw an error. #374

wawer77 opened this issue Sep 27, 2023 · 0 comments · Fixed by #375
Labels
bug Something isn't working

Comments

@wawer77
Copy link

wawer77 commented Sep 27, 2023

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
@koic koic transferred this issue from rubocop/rubocop Sep 27, 2023
@koic koic added the bug Something isn't working label Sep 27, 2023
koic added a commit to koic/rubocop-performance that referenced this issue Sep 27, 2023
Fixes rubocop#374.

This PR fixes an error for `Performance/MapMethodChain`
when using `map` method chain without receiver.
@koic koic closed this as completed in #375 Oct 1, 2023
koic added a commit that referenced this issue Oct 1, 2023
…thod_chain

[Fix #374] Fix an error for `Performance/MapMethodChain`
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.

2 participants