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
Address frozen_string_literal
no longer applying to interpolated strings
#8743
Address frozen_string_literal
no longer applying to interpolated strings
#8743
Conversation
Interpolated and non-interpolated strings will be frozen differently. Splitting their tests will make the change clearer.
As per https://bugs.ruby-lang.org/issues/17104, interpolated string literals will no longer be frozen when frozen string literals are enabled. Therefore, two changes must happen to how we treat interpolated literals - Style/MutableConstant should enforce freezing them - Style/RedundantFreeze should not consider it redundant to freeze them
Reading the conversation in the ticket it seems it's not clear if that change will be in Ruby 3.0 (despite the changes that were merged), so let's wait for the final release before changing anything. |
I'll close the PR for now in the interest of reducing the number of outstanding PRs. We'll revisit it down the road. |
FWIW, I don't see the intrinsic interest in this. |
@bbatsov @marcandre Since that change has indeed made it into Ruby 3, should we consider re-opening this? We are running into the same issue in GitLab, and are now considering to either disable this Cop or patch this in RuboCop itself. https://gitlab.com/gitlab-org/gitlab-styles/-/merge_requests/87 |
Since Ruby 3.0 or higher interpolated strings are not frozen automatically anymore. Therefore, two changes must happen to how we treat interpolated literals * Style/MutableConstant should enforce freezing them * Style/RedundantFreeze should not consider it redundant to freeze them Strongly inspired by rubocop#8743
Since Ruby 3.0 or higher interpolated strings are not frozen automatically anymore. Therefore, two changes must happen to how we treat interpolated literals * Style/MutableConstant should enforce freezing them * Style/RedundantFreeze should not consider it redundant to freeze them Strongly inspired by #8743
As per Ruby Feature #17104, interpolated string literals will no longer be frozen when frozen string literals are enabled.
Therefore, two changes must happen to how we treat interpolated literals
Style/MutableConstant
should enforce freezing themStyle/RedundantFreeze
should not consider it redundant to freeze themThis PR makes those changes.
Before submitting the PR make sure the following are checked:
[Fix #issue-number]
(if the related issue exists).master
(if not - rebase it).bundle exec rake default
. It executes all tests and RuboCop for itself, and generates the documentation.Fixes #8703