diff --git a/CHANGELOG.md b/CHANGELOG.md index d13e308d8c..524175e326 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ## master (unreleased) +### Changes + +* [#228](https://github.com/rubocop/rubocop-performance/pull/228): Mark `Performance/RedundantMerge` as unsafe. ([@dvandersluis][]) + ## 1.10.2 (2021-03-23) ### Bug fixes diff --git a/config/default.yml b/config/default.yml index 17f3e7c249..8f4feb984a 100644 --- a/config/default.yml +++ b/config/default.yml @@ -220,7 +220,9 @@ Performance/RedundantMerge: Description: 'Use Hash#[]=, rather than Hash#merge! with a single key-value pair.' Reference: 'https://github.com/JuanitoFatas/fast-ruby#hashmerge-vs-hash-code' Enabled: true + Safe: false VersionAdded: '0.36' + VersionChanged: '1.11' # Max number of key-value pairs to consider an offense MaxKeyValuePairs: 2 diff --git a/lib/rubocop/cop/performance/redundant_merge.rb b/lib/rubocop/cop/performance/redundant_merge.rb index d986cc3a09..ee920ef50a 100644 --- a/lib/rubocop/cop/performance/redundant_merge.rb +++ b/lib/rubocop/cop/performance/redundant_merge.rb @@ -8,6 +8,9 @@ module Performance # You can set the maximum number of key-value pairs to consider # an offense with `MaxKeyValuePairs`. # + # This cop is marked as unsafe because RuboCop cannot determine if the + # receiver of `merge!` is actually a hash or not. + # # @example # # bad # hash.merge!(a: 1)