Style/RedundantFreeze to remove redudant
Since Rails 6.0 will support Ruby 2.4.1 or higher
I'd like to hear from Rails committers for this change since Rails 5.2 will supports Ruby 2.2, this change itself should not be backported but also it could make other backports complex.
I wonder how many of these are extremely performance-critical. For most, it seems fine to backport to 5.2, just to make future maintenance easier: things being slightly slower on 5.2 + 2.2 doesn't sound like a big deal... I'm just not sure how we'd identify any where it makes a catastrophic difference.
Otherwise, we can wait a while and then merge this in a few months, when 5.2 backports have settled down.
I think we might want to keep the explicit
Thanks for the review. I did not expect that backporting this change to 5-2-stable is possible.
Agreed. I have excluded 3 test files which have tests expecting a frozen string in case of backporting and respecting the intention of the tests.
We're already doing that on any other literals where we don't explicitly call
I do think it's reasonable for us to strongly recommend a newer ruby than the oldest we support, and to bump that recommendation more freely: we want 5.2 to work on almost-already-EOL 2.2, but I don't see myself feeling bad it if doesn't work well.
Since Rails 6.0 will support Ruby 2.4.1 or higher `# frozen_string_literal: true` magic comment is enough to make string object frozen. This magic comment is enabled by `Style/FrozenStringLiteralComment` cop. * Exclude these files not to auto correct false positive `Regexp#freeze` - 'actionpack/lib/action_dispatch/journey/router/utils.rb' - 'activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb' It has been fixed by rubocop/rubocop#6333 Once the newer version of RuboCop released and available at Code Climate these exclude entries should be removed. * Replace `String#freeze` with `String#-@` manually if explicit frozen string objects are required - 'actionpack/test/controller/test_case_test.rb' - 'activemodel/test/cases/type/string_test.rb' - 'activesupport/lib/active_support/core_ext/string/strip.rb' - 'activesupport/test/core_ext/string_ext_test.rb' - 'railties/test/generators/actions_test.rb'