-
-
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 interpolation in multi line strings #2549
Comments
This has already been brought up on this bug tracker before. The RC developers like the current style. If you would like to code up a PR to make this configurable, it will be appreciated. |
Thanks. I've searched the issues for StringLiterals and didn't find anything related to multi-line strings. Can you point me to the issue? I'd like to read the pro's for the current style, as I didn't even think that mixing quotes in a single string is even allowed:
As for your suggestion, I've just taken a quick look at the code and don't think I could add a configuration option, as it seems as if the checked node is not the entire multi-lined string but each single line is checked one by one. Unfortunately I don't have enough knowledge to alter that behavior. |
@maia It may have been in the style guide repo. When you have string literals which are concatenated like this: "A string" \
'another one' ...they are parsed as a So you could add an Then, call |
@alexdowad Thanks, I didn't find it in the style guide repo, so maybe the current style is not considered best practice. As for the PR, in case I can find a few spare hours to dig deeper in the internals of rubocop, I will make an attempt, but please don't count on it. |
I think we can add a config parameter to enforce the use of consistent quote types for multiline-continuation strings. Question: what should the new config parameter be called? |
How about TreatMultiLinesAsGroup or ConsistentQuotesInMultiLines ? |
|
Just pushed a fix for this one to my open PR. The new config parameter is called |
That's great news, thanks a lot! |
Thanks a lot! |
Rubocop seems to check multi-lined strings one line by the other, and if there's no interpolation in the current line it will report. I do believe that all lines of a multi-line string should use double-quoted strings if there's an interpolation in at least one line:
Is this an incorrect report by rubocop, or is it suggested to mix single and double quotes in multi-line strings?
The text was updated successfully, but these errors were encountered: