Skip to content

Commit

Permalink
[Fix #7446] Add merge to NONMUTATING_METHODS
Browse files Browse the repository at this point in the history
Fixes #7446

Now, if `merge` is used in a void context, the `Lint/Void` cop will
register an offense and the mutating `merge!` method will be suggested.
  • Loading branch information
cstyles authored and bbatsov committed Oct 21, 2019
1 parent d6ceaa3 commit e436938
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Expand Up @@ -8,6 +8,10 @@
* [#7438](https://github.com/rubocop-hq/rubocop/issues/7438): Fix assignment edge-cases in `Layout/MultilineAssignmentLayout`. ([@gsamokovarov][])
* [#7449](https://github.com/rubocop-hq/rubocop/pull/7449): Make `Style/IfUnlessModifier` respect `rubocop:disable` comments for `Metrics/LineLength`. ([@jonas054][])

### Changes

* [#7446](https://github.com/rubocop-hq/rubocop/issues/7446): Add `merge` to list of non-mutating methods. ([@cstyles][])

## 0.75.1 (2019-10-14)

### Bug fixes
Expand Down Expand Up @@ -4234,3 +4238,4 @@
[@laurenball]: https://github.com/laurenball
[@jfhinchcliffe]: https://github.com/jfhinchcliffe
[@jdkaplan]: https://github.com/jdkaplan
[@cstyles]: https://github.com/cstyles
8 changes: 4 additions & 4 deletions lib/rubocop/cop/lint/void.rb
Expand Up @@ -55,10 +55,10 @@ class Void < Cop
VOID_CONTEXT_TYPES = %i[def for block].freeze
NONMUTATING_METHODS = %i[capitalize chomp chop collect compact
delete_prefix delete_suffix downcase
encode flatten gsub lstrip map next reject
reverse rotate rstrip scrub select shuffle
slice sort sort_by squeeze strip sub succ
swapcase tr tr_s transform_values
encode flatten gsub lstrip map merge next
reject reverse rotate rstrip scrub select
shuffle slice sort sort_by squeeze strip sub
succ swapcase tr tr_s transform_values
unicode_normalize uniq upcase].freeze

def on_block(node)
Expand Down

0 comments on commit e436938

Please sign in to comment.