lib/rubocop/cop/style/hash_transform_values.rb in rubocop-1.21.0 vs lib/rubocop/cop/style/hash_transform_values.rb in rubocop-1.22.0
- old
+ new
@@ -6,15 +6,13 @@
# This cop looks for uses of `_.each_with_object({}) {...}`,
# `_.map {...}.to_h`, and `Hash[_.map {...}]` that are actually just
# transforming the values of a hash, and tries to use a simpler & faster
# call to `transform_values` instead.
#
- # This can produce false positives if we are transforming an enumerable
- # of key-value-like pairs that isn't actually a hash, e.g.:
- # `[[k1, v1], [k2, v2], ...]`
- #
- # This cop should only be enabled on Ruby version 2.4 or newer
- # (`transform_values` was added in Ruby 2.4.)
+ # @safety
+ # This cop is unsafe, as it can produce false positives if we are
+ # transforming an enumerable of key-value-like pairs that isn't actually
+ # a hash, e.g.: `[[k1, v1], [k2, v2], ...]`
#
# @example
# # bad
# {a: 1, b: 2}.each_with_object({}) { |(k, v), h| h[k] = foo(v) }
# Hash[{a: 1, b: 2}.collect { |k, v| [k, foo(v)] }]