-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Frozen-string-literal comment detection does not detect comment headers. #2643
Comments
Should that be |
The example I gave clearly indicates that the way I did it works... Rubocop does pick up the comment without the header, try using the master branch instead of the stable release. |
Yes it should be |
@durrantm sorry, but you are wrong.
|
I bumped my head against this one today: @envygeeks in the example you show at the top of this thread, you wrote |
I'm having a hard time finding a definitive answer on the format of Ruby's magic comments, so I struggled through Ruby's I'm pretty sure this part means dashes and underscores are equivalent and this case-insensitive comparison means case doesn't matter. I suspect a minor adjustment to the regex in |
@mikegee correct that adjusting that regex will fix the issue.
You are correct that it is barely documented. I included three relevant links in the docs for that |
@envygeeks While looking into this issue I found that the Since UTF-8 is the default source encoding since Ruby 2.0, this issue is moot in the particular snippet you posted. This can be enforced by enabling Style/Encoding:
Enabled: true
EnforcedStyle: always
|
Ruby's "magic comments" may use dashes instead of underscores [1] and are case-insensitive [2]. [1]: https://github.com/ruby/ruby/blob/78b95b49f8715a4782f5b9bdc4c163e445cdc303/parse.y#L7134-L7136 [2]: https://github.com/ruby/ruby/blob/78b95b49f8715a4782f5b9bdc4c163e445cdc303/parse.y#L7138
Ruby's "magic comments" may use dashes instead of underscores [1] and are case-insensitive [2]. [1]: https://github.com/ruby/ruby/blob/78b95b49f8715a4782f5b9bdc4c163e445cdc303/parse.y#L7134-L7136 [2]: https://github.com/ruby/ruby/blob/78b95b49f8715a4782f5b9bdc4c163e445cdc303/parse.y#L7138
A comment header does not affect
Frozen-string-literal: true
in Ruby, however, when using comment headers Rubocop does not properly detectFrozen-string-literal: true
:The text was updated successfully, but these errors were encountered: