rubocop / rubocop-performance

An extension of RuboCop focused on code performance checks.
https://docs.rubocop.org/rubocop-performance
MIT License
670 stars 79 forks source link

Improve explanation for safety of `MapCompact` autocorrection in docs #450

Closed Splines closed 4 months ago

Splines commented 4 months ago

When I first read about the Performance/MapCompact cop, I didn't understand the following sentence at first glance:

This cop's autocorrection is unsafe because map { ... }.compact that is not compatible with filter_map.

This fixes #280. The issue was already closed, however, it "fixes" it in the sense that the underlying confusion should be mitigated by a better wording in the docs.


Before submitting the PR make sure the following are checked:

🛑 As a sidenote: Note that in the last checklist item, you're linking to the contribution guide of rubocop (via the changelog entry format link), not that of this repo.

koic commented 4 months ago

Once you have addressed the comments, please squash the commits into one.

Splines commented 4 months ago

Thanks for your review. I addressed all your points.

Note that I ran bundle exec rake default again and 8 examples failed in rspec. After that, I executed the command again and now everything is passing and RuboCop did not detect any offenses. After yet another execution of that command, still everything works as expected ;)

koic commented 4 months ago

Thanks!