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

False positive for Style/RedundantFreeze #6996

Closed
bquorning opened this issue Apr 29, 2019 · 0 comments
Closed

False positive for Style/RedundantFreeze #6996

bquorning opened this issue Apr 29, 2019 · 0 comments
Assignees
Labels

Comments

@bquorning
Copy link
Contributor

Since #6784, an input like ('a' * 20).freeze would cause Style/RedundantFreeze to say the freeze was not necessary. Since the parenthesised expression produces a mutable string, the freeze call is indeed necessary.


Expected behavior

Freezing the result of ('a' * 20) should be ok.

Actual behavior

Freezing the result of ('a' * 20) makes Style/RedundantFreeze to say the freeze is redundant.

Steps to reproduce the problem

❯ cat test.rb
('a' * 20).freeze
❯ bundle exec rubocop --only Style/RedundantFreeze -- test.rb
Inspecting 1 file
C

Offenses:

test.rb:1:1: C: Style/RedundantFreeze: Do not freeze immutable objects, as freezing them has no effect.
('a' * 20).freeze
^^^^^^^^^^^^^^^^^

1 file inspected, 1 offense detected

RuboCop version

$ bundle exec rubocop -V
0.68.0 (using Parser 2.6.2.1, running on ruby 2.6.1 x86_64-darwin18)
@bquorning bquorning added the bug label Apr 29, 2019
@bquorning bquorning self-assigned this Apr 29, 2019
bquorning added a commit to bquorning/rubocop that referenced this issue Apr 29, 2019
Fix a false positive for `Style/RedundantFreeze` when freezing the result of `String#*`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant