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

Style/RedundantFreeze stop considering ENV values as immutable #10099

Merged
merged 1 commit into from Sep 22, 2021
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions changelog/fix_redundant_freeze_env_values.md
@@ -0,0 +1 @@
* [#10099](https://github.com/rubocop/rubocop/pull/10099): Update`Style/RedundantFreeze` to stop considering `ENV` values as immutable. ([@byroot][])
1 change: 0 additions & 1 deletion lib/rubocop/cop/style/redundant_freeze.rb
Expand Up @@ -59,7 +59,6 @@ def strip_parenthesis(node)
(begin (send {float int} {:+ :- :* :** :/ :% :<<} _))
(begin (send !{(str _) array} {:+ :- :* :** :/ :%} {float int}))
(begin (send _ {:== :=== :!= :<= :>= :< :>} _))
(send (const {nil? cbase} :ENV) :[] _)
(send _ {:count :length :size} ...)
(block (send _ {:count :length :size} ...) ...)
}
Expand Down
4 changes: 2 additions & 2 deletions spec/rubocop/cop/style/redundant_freeze_spec.rb
Expand Up @@ -20,8 +20,6 @@
it_behaves_like 'immutable objects', '1.5'
it_behaves_like 'immutable objects', ':sym'
it_behaves_like 'immutable objects', ':""'
it_behaves_like 'immutable objects', "ENV['foo']"
it_behaves_like 'immutable objects', "::ENV['foo']"
it_behaves_like 'immutable objects', "'foo'.count"
it_behaves_like 'immutable objects', '(1 + 2)'
it_behaves_like 'immutable objects', '(2 > 1)'
Expand All @@ -44,6 +42,8 @@
it_behaves_like 'mutable objects', "('a' * 20)"
it_behaves_like 'mutable objects', '(a + b)'
it_behaves_like 'mutable objects', '([42] * 42)'
it_behaves_like 'mutable objects', "ENV['foo']"
it_behaves_like 'mutable objects', "::ENV['foo']"

it 'allows .freeze on method call' do
expect_no_offenses('TOP_TEST = Something.new.freeze')
Expand Down