Skip to content

Commit

Permalink
Merge pull request #450 from Splines/docs/mapcompact-safety
Browse files Browse the repository at this point in the history
Improve explanation for safety of `MapCompact` autocorrection in docs
  • Loading branch information
koic committed Apr 18, 2024
2 parents 6d72c73 + bcc4f38 commit 3e9d1bc
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/rubocop/cop/performance/map_compact.rb
Expand Up @@ -8,8 +8,9 @@ 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` that is not
# compatible with `filter_map`.
# This cop's autocorrection 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`.
#
# [source,ruby]
# ----
Expand Down

0 comments on commit 3e9d1bc

Please sign in to comment.