Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog/fix_mark_performance_map_compact_cop_as.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* [#500](https://github.com/rubocop/rubocop-performance/issues/500): Mark `Performance/MapCompact` cop as unsafe. ([@jbpextra][])
2 changes: 1 addition & 1 deletion config/default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ Performance/IoReadlines:
Performance/MapCompact:
Description: 'Use `filter_map` instead of `collection.map(&:do_something).compact`.'
Enabled: pending
SafeAutoCorrect: false
Safe: false
VersionAdded: '1.11'

Performance/MapMethodChain:
Expand Down
2 changes: 1 addition & 1 deletion lib/rubocop/cop/performance/map_compact.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module Performance
# This cop identifies places where `map { ... }.compact` can be replaced by `filter_map`.
#
# @safety
# This cop's autocorrection is unsafe because `map { ... }.compact` might yield
# This cop is unsafe because `map { ... }.compact` might yield
# different results than `filter_map`. As illustrated in the example, `filter_map`
# also filters out falsy values, while `compact` only gets rid of `nil`.
#
Expand Down