-
Notifications
You must be signed in to change notification settings - Fork 504
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
Ignore line length in string literals #659
Comments
Why it should be accepted? 🤔 You could split string literal using |
Since comments and raw strings are already not taken into account when checking line length. Splitting string literal is risky - this string may be the expected value in a test and you may miss something if the string is contained in 2 lines: assertThat(string).isEqualTo(
"very very long" +
"string but I missed space between lines"
) Disabling blocks are very invasive as you need to open and close them, so you get 1:2 signal to noise ratio: 2 lines to satisfy ktlint in 1 line of code. |
Another way - would be support disabling particular rules via |
Supporting |
I agree, string in exceptions, deprecations etc should be allowed to be of any length as it's very inconvenient to split them. |
Would like to add that back ticked function names in tests should also be handled / ignored:
In this case it cannot be split. |
+1 |
Just adding my two cents for this issue that we hit in our current project. in
|
I have the same problem, long string literals are common and splitting them is not a working solution and does not work with const values. I've submitted 2 PR that aim to solve this problem in different ways :
I would much rather prefer the second approach but I'm glad if one of them is a accepted/improved or the issue taken down in some way 🙂 |
looks like you can define as |
@Tapchicoma what about Room database Query? if we break like normal string, we lose the Query syntax support from Room 🤔 |
Value |
String literals will not be ignored when checking whether the maximum length of the line is exceeded. Consider using a raw string literal instead, or the |
Let's have `.editorconfig'
and Kotlin file:
Ktlint 0.35.0 rejects both declarations:
I think at least line 2 should be accepted - it contains only whitespace and a string literal.
The text was updated successfully, but these errors were encountered: