-
-
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
Style/StringLiterals ignores strings with non-ascii characters #3017
Comments
Hi! This was by design. Please see lines 231-238 of # If double quoted string literals are found in Ruby code, and they are
# not the preferred style, should they be flagged?
def double_quotes_acceptable?(string)
# If a string literal contains hard-to-type characters which would
# not appear on a "normal" keyboard, then double-quotes are acceptable
double_quotes_required?(string) ||
string.codepoints.any? { |cp| cp < 32 || cp > 126 }
end ...I don't remember what the reasoning was behind this code, but if you want to argue for something else, please do so. Anyways, this is not a "bug" in the sense of unintentional behavior. |
I don't remember this either. |
LOL. I think it was me who wrote it. |
Yeah, I was git-blaming this and it seems so! :) |
OK, I remember why this is so. The Ruby parser doesn't differentiate between your string and So when we find a double-quoted string literal with a |
@alexdowad I'm not sure I quite get it. What's the technical limitation to not fix this? |
The "technical limitation" is that if we fix the handling of That is, unless you actually re-parse the source code for the string yourself, and distinguish between the 2 cases. The AST which |
I guess this would be the way to go, then. Maybe I'll give it a try! |
results in
whereas
results in
The text was updated successfully, but these errors were encountered: