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

Performance/MapCompact autocorrection leads to faulty syntax #247

Closed
koppen opened this issue May 20, 2021 · 0 comments · Fixed by #248
Closed

Performance/MapCompact autocorrection leads to faulty syntax #247

koppen opened this issue May 20, 2021 · 0 comments · Fixed by #248
Labels
bug Something isn't working

Comments

@koppen
Copy link

koppen commented May 20, 2021

Expected behavior

Given the original code:

players.
  map(&:score).
  compact.
  max

I expect rubocop -A --only Performance/MapCompact to correct the code to

players.
  filter_map(&:score).
  max

Actual behavior

Instead, rubocop -A --only Performance/MapCompact corrects the code to

players.
  filter_map(&:score)
  max

which ultimately results in

undefined local variable or method `max' for main:Object (NameError)

RuboCop version

$ bundle exec rubocop -V
1.14.0 (using Parser 3.0.1.1, rubocop-ast 1.5.0, running on ruby 2.7.3 x86_64-darwin19)
  - rubocop-performance 1.11.3
@koic koic added the bug Something isn't working label May 20, 2021
koic added a commit to koic/rubocop-performance that referenced this issue May 20, 2021
…mpact

Fixes rubocop#247.

This PR fix an incorrect auto-correct for Performance/MapCompact when
using multi-line trailing dot method calls.
koic added a commit to koic/rubocop-performance that referenced this issue May 20, 2021
…ompact`

Fixes rubocop#247.

This PR fix an incorrect auto-correct for `Performance/MapCompact` when
using multi-line trailing dot method calls.
koic added a commit to koic/rubocop-performance that referenced this issue May 20, 2021
…ompact`

Fixes rubocop#247.

This PR fixes an incorrect auto-correct for `Performance/MapCompact` when
using multi-line trailing dot method calls.
@koic koic closed this as completed in #248 May 21, 2021
koic added a commit that referenced this issue May 21, 2021
…rmance_map_compact_cop

[Fix #247] Fix an incorrect auto-correct for `Performance/MapCompact`
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