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

Improve explanation for safety of MapCompact autocorrection in docs #450

Merged
merged 1 commit into from Apr 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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