-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Frozen String Literal Behavior is Confusing #7426
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
Comments
Good points.
Yeah, it will be easy to understand if it is documented.
AFAIK, there is no such configure option, so enhancement will be necessary. |
@koic : Thanks for your reply! I imagine a docs change is something people wouldn't object to. The enhancement would be nice. Would be curious to know if people have any objections. |
I assumed the For reference, current RuboCop default configuration options are;
Would it make sense to add a new SupportedStyle of
I think defaulting to |
@olliebennett : My thoughts exactly. I wanted to see if there were any maintainer objections though on this before proceeding with an enhancement. |
This adds another style to Style/FrozenStringLiteralComment that enforces that the comment is always enabled, that is, it requires that string literals are always frozen. The default style, `always`, enforces that the comment exists but does not enforce that the comment is enabled. This also differentiates the offense message for the `always` and `always_true` styles. It changes the offense message when using the `always` style to be less specific, since the old version of the message implied that the only acceptable value of the frozen_string_literal comment was `true`. In fact, in the `always` style, either `true` or `false` is acceptable. The new `always_true` style uses that preexisting message, since when using that style it is required that the value of the frozen_string_literal comment is `true`.
According to the docs, my understanding was that in order for the cop to be satisfied, we had to add
# frozen_string_literal: true
to the top of the file.However, after finding what appeared to be a false negative in one of my projects, I found #7241 and its corresponding fix in #7251 that highlighted that adding
# frozen_string_literal: false
to the top can still pass this cop. Two points:false
is accepted in the magic comment# frozen_string_literal: true
only?Rubocop Info
The text was updated successfully, but these errors were encountered: