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 invalid syntax #236

Closed
dvandersluis opened this issue Apr 23, 2021 · 1 comment · Fixed by #237
Closed

Performance/MapCompact autocorrection leads to invalid syntax #236

dvandersluis opened this issue Apr 23, 2021 · 1 comment · Fixed by #237
Labels
bug Something isn't working

Comments

@dvandersluis
Copy link
Member

dvandersluis commented Apr 23, 2021

Original code:

MyClass
  .map(&:foo)
  .compact
  .first

Performance/MapCompact autocorrects the code to:

MyClass
  .filter_map(&:foo)
                    # <== blank line added here
  .first

Which leads to a syntax error:

E: Lint/Syntax: unexpected token tDOT
(Using Ruby 3.0 parser; configure using TargetRubyVersion parameter, under AllCops)
            .first
            ^

RuboCop version

$ rubocop -V
1.13.0 (using Parser 3.0.1.0, rubocop-ast 1.4.1, running on ruby 3.0.1 x86_64-darwin18)
  - rubocop-performance 1.11.0
  - rubocop-rails 2.9.1
  - rubocop-rspec 2.2.0
@koic koic added the bug Something isn't working label Apr 24, 2021
koic added a commit to koic/rubocop-performance that referenced this issue Apr 24, 2021
…ompact`

Fixes rubocop#236.

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

Fixes rubocop#236.

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

Fixes rubocop#236.

This PR fix an incorrect auto-correct for `Performance/MapCompact`
when using multi-line leading dot method calls.
@koic koic closed this as completed in #237 Apr 25, 2021
koic added a commit that referenced this issue Apr 25, 2021
…rmance_map_compact

[Fix #236] Fix an incorrect auto-correct for `Performance/MapCompact`
@dvandersluis
Copy link
Member Author

Thanks @koic! ❤️

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