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

Reports strings as mutable objects assigned to constants issue #50

Closed
nielsm opened this issue Feb 16, 2016 · 4 comments
Closed

Reports strings as mutable objects assigned to constants issue #50

nielsm opened this issue Feb 16, 2016 · 4 comments

Comments

@nielsm
Copy link

nielsm commented Feb 16, 2016

Given the following constant:

SOMETHING = 'something'

Will generate this error:

Freeze mutable objects assigned to constants.

The help description says this should only apply to array or hashes. Is it being too literal in considering a string an Array? This only began with the 0.20 release of the CLI

@nielsm
Copy link
Author

nielsm commented Feb 16, 2016

Incidentally, this was also noticed directly in Rubocop: rubocop/rubocop#2630

@gdiggs
Copy link
Contributor

gdiggs commented Feb 16, 2016

@nielsm That check is correct in referring to strings as well, depending on the ruby version. Before Ruby 2.3, strings were mutable (https://wyeworks.com/blog/2015/12/1/immutable-strings-in-ruby-2-dot-3). Looks like rubocop fixed this in 0.37.2, which we are using. Have you tried running codeclimate engines:install and then running codeclimate analyze again?

@nielsm
Copy link
Author

nielsm commented Feb 16, 2016

Yes, just updated, which is when I started getting the errors, but I'm running Ruby < 2.3

@wfleming
Copy link
Contributor

Hi @nielsm,

I think this is just a case of RuboCop's help description not being exhaustive: strings do qualify as mutable objects for these cases. rubocop/rubocop#2630 is specifically about supporting the new auto-frozen strings on Ruby 2.3, so it doesn't sound like that applies in your case. The previous version of rubocop we were using also reported SOMETHING = 'something' as a problem in my testing, so if you weren't seeing these reported before I think that was a bug that has now been fixed.

I'm going to go ahead & close this, but let me know if you have further questions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants