Skip to content

Commit

Permalink
[Fix #6996] Allow freezing result of String#* (#6997)
Browse files Browse the repository at this point in the history
Fix a false positive for `Style/RedundantFreeze` when freezing the result of `String#*`.
  • Loading branch information
bquorning authored and bbatsov committed Apr 29, 2019
1 parent 619740f commit 4f05ea4
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -5,6 +5,7 @@
### Bug fixes

* [#6995](https://github.com/rubocop-hq/rubocop/pull/6995): Fix an incorrect auto-correct for `Style/RedundantParentheses` when enclosed in parentheses at `while-post` or `until-post`. ([@koic][])
* [#6996](https://github.com/rubocop-hq/rubocop/pull/6996): Fix a false positive for `Style/RedundantFreeze` when freezing the result of `String#*`. ([@bquorning][])
* [#6998](https://github.com/rubocop-hq/rubocop/pull/6998): Fix autocorrect of `Naming/RescuedExceptionsVariableName` to also rename all references to the variable. ([@Darhazer][])

## 0.68.0 (2019-04-29)
Expand Down
2 changes: 1 addition & 1 deletion lib/rubocop/cop/style/redundant_freeze.rb
Expand Up @@ -54,7 +54,7 @@ def strip_parenthesis(node)
def_node_matcher :operation_produces_immutable_object?, <<-PATTERN
{
(begin (send {float int} {:+ :- :* :** :/ :% :<<} _))
(begin (send _ {:+ :- :* :** :/ :%} {float int}))
(begin (send !(str _) {:+ :- :* :** :/ :%} {float int}))
(begin (send _ {:== :=== :!= :<= :>= :< :>} _))
(send (const nil? :ENV) :[] _)
(send _ {:count :length :size} ...)
Expand Down
1 change: 1 addition & 0 deletions spec/rubocop/cop/style/redundant_freeze_spec.rb
Expand Up @@ -46,6 +46,7 @@
it_behaves_like 'mutable objects', '(1..5)'
it_behaves_like 'mutable objects', '(1...5)'
it_behaves_like 'mutable objects', "('a' + 'b')"
it_behaves_like 'mutable objects', "('a' * 20)"
it_behaves_like 'mutable objects', '(a + b)'

it 'allows .freeze on method call' do
Expand Down

0 comments on commit 4f05ea4

Please sign in to comment.