From bcc4f383d788059b457ceb07d86577ecfefd49fd Mon Sep 17 00:00:00 2001 From: Splines Date: Wed, 17 Apr 2024 23:20:44 +0200 Subject: [PATCH] Improve wording of `filter_map` autocorrect safety in docs --- lib/rubocop/cop/performance/map_compact.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/rubocop/cop/performance/map_compact.rb b/lib/rubocop/cop/performance/map_compact.rb index 2bddcc2e92..34e4646c0a 100644 --- a/lib/rubocop/cop/performance/map_compact.rb +++ b/lib/rubocop/cop/performance/map_compact.rb @@ -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] # ----