The bug you're experiencing might have already be reported!
Please search in the issues before creating one.
Method after multiline text
"""
|longtext longtext longtext longtext longtext longtext
|longtext longtext longtext longtext longtext longtext
|longtext longtext longtext longtext longtext longtext
|longtext longtext longtext longtext longtext longtext
""".trimMargin("|")
Ktlint gives 2 error.
Argument should be on a separate line (unless all arguments can fit a single line)ktlintTestSourceSetCheck
Missing newline before ")"
0.38.0-alpha01ktlintCheck from https://github.com/JLLeitschuh/ktlint-gradleThanks for the report @kozaxinan. To clarify: both errors are reporting on the """.trimMargin("|") line? And can you also confirm that this is a regression with the 0.38.0 alpha? (i.e. didn't occur in 0.37.2).
Likely introduced by this commit https://github.com/pinterest/ktlint/commit/a94b43fa8978a1cbe882b09b8c6112e612fb66b2
Yes that is a regression in alpha and yes it is on trimIndent line.
@kozaxinan I could not reproduce it with following Kotlin file:
val test =
"""
|longtext longtext longtext longtext longtext longtext
|longtext longtext longtext longtext longtext longtext
|longtext longtext longtext longtext longtext longtext
|longtext longtext longtext longtext longtext longtext
""".trimMargin("|")
Maybe you could provide full Kotlin file or link to it?
class Test {
fun someMethod(str: String) = Unit
val someString = someMethod(
"""
longtext longtext longtext longtext longtext longtext longtext longtext
longtext longtext longtext longtext longtext longtext longtext longtext
longtext longtext longtext longtext longtext longtext longtext longtext
longtext longtext longtext longtext longtext longtext longtext longtext
longtext longtext longtext longtext longtext longtext longtext longtext
""".trimIndent('|')
)
}
Running ktlint on this file gives two errors.
/Test.kt:14:20: Argument should be on a separate line (unless all arguments can fit a single line)
/Test.kt:14:23: Missing newline before ")"
@kozaxinan sorry, but you example only produces indentation errors for me with latest build from master:
Test.kt:3:1: Unexpected indentation (2) (should be 4)
Test.kt:5:1: Unexpected indentation (2) (should be 4)
Test.kt:6:1: Unexpected indentation (4) (should be 8)
Test.kt:6:5: Unexpected indentation (expected 6, actual 4)
Test.kt:13:1: Unexpected indentation (2) (should be 4)
Could you try 0.38.0 release?
I tested that code example with 0.38 and command line ktlint.
I will test issue in a fresh repo.
Do you have .editorconfig in your repo? Could you paste content of it here? It may affect ktlint results.
I checked code in empty folder outside of project without editorconfig.
Running 'ktlint --android' gives errors for me with 0.38
Yeah, with --android I could also reproduce it :+1:
@kozaxinan with 0.39.0 release you could disable experimental 'argument-list-wrapping' rule to suppress this issue.