Is there a ktlint directive to force multi-line st...
# ktlint
l
Is there a ktlint directive to force multi-line strings to use
"""
rather than a bunch of concatenated (
+
) strings? A recent upgrade inadvertently converted… all of our queries in JPA repositories to the latter, which has made them substantially more ugly and hard to manage. I want to blanket-undo that damage.
j
Git commit revert? Or try an OpenRewrite recipe
p
Ktlint does not support this. But you can use the IDEA inspection below:
a
l
Unfortunately it cannot be git reverted at this point. (It was one huge upgrade PR from our great-grand-boss Director-level that got merged prematurely, but upgraded Kotlin, Spring, and KTlint without really any meaningful validation. We’ve spent the last week undoing the damage and aren’t done yet.)
@Paul Dingemans Hm, I appear to have that set already in the IDE.
What’s OpenRewrite?
p
You can just run the inspection in the IDEA again
l
Hm. Looks like that’s converting it to one very long line. If it’s already a “”" string, would ktlint multi-line that without breaking it up?
I’m not sure how to run that inspection over the whole code base… I see how to do it in each case individually.
Hm, no, it doesn’t. Even if I set a line length, it says it cannot reformat it. Interesting…
p
the max line length rule can indeed not wrap strings automatically.
There is no algorithm that would work well.
l
Drat. Looks like this is going to require manual work to clean up no matter what.