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 autocorrect is too greedy #238

Closed
jcoyne opened this issue May 4, 2021 · 0 comments · Fixed by #239
Closed

Performance/MapCompact autocorrect is too greedy #238

jcoyne opened this issue May 4, 2021 · 0 comments · Fixed by #239
Labels
bug Something isn't working

Comments

@jcoyne
Copy link

jcoyne commented May 4, 2021

I ran the autocorrect on this code and it removed the trailing end as well as the .join("\n"). This results in a syntax error.

   def participant_change_description
     %i[added_managers added_depositors added_reviewers
-       removed_managers removed_depositors removed_reviewers].map do |field_name|
+       removed_managers removed_depositors removed_reviewers].filter_map do |field_name|
       field_changes = send(field_name)
       next if field_changes.blank?

       "#{field_name.to_s.humanize}: #{field_changes.map(&:sunetid).join(', ')}"
-    end.compact.join("\n")
   end
@dvandersluis dvandersluis transferred this issue from rubocop/rubocop May 4, 2021
@koic koic added the bug Something isn't working label May 4, 2021
koic added a commit to koic/rubocop-performance that referenced this issue May 4, 2021
…ompact`

Fixes rubocop#238.

This PR fixes an incorrect auto-correct for `Performance/MapCompact`
when using `map do ... end.compact`.
koic added a commit to koic/rubocop-performance that referenced this issue May 4, 2021
…ompact`

Fixes rubocop#238.

This PR fixes an incorrect auto-correct for `Performance/MapCompact`
when invoking a method after `map { ... }.compact`.
koic added a commit to koic/rubocop-performance that referenced this issue May 4, 2021
…ompact`

Fixes rubocop#238.

This PR fixes an incorrect auto-correct for `Performance/MapCompact`
when invoking a method after `map { ... }.compact` on the same line.
koic added a commit to koic/rubocop-performance that referenced this issue May 4, 2021
…ompact`

Fixes rubocop#238.

This PR fixes an incorrect auto-correct for `Performance/MapCompact`
when invoking a method after `map { ... }.compact` on the same line.
@koic koic closed this as completed in #239 May 4, 2021
koic added a commit that referenced this issue May 4, 2021
…rformance_map_compact

[Fix #238] 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