https://kotlinlang.org logo
#detekt
Title
# detekt
l

LeoColman

06/04/2022, 5:51 PM
Hello guys! I think I might have found a bug in Detekt. https://github.com/LeoColman/Petals/commit/7c16d82a999f3f65b30f2c19bd411f6d3db1c8de#diff-6bbb3aa0c72ccab5cb844fd4b[…]8ab4c6110c06add1d36615718f64R62 In this commit we implemented an workaround to the following issue:
Copy code
AndroidView({ LineChart(it) }, Modifier) {
    val a = "abc"
    val b = "def
}
This codes makes detekt fail and autocorrect it to
Copy code
AndroidView({ LineChart(it) }, Modifier) {
val a = "abc"
val b = "def
}
A workaround for this case is
Copy code
AndroidView(::LineChart, Modifier) {
    val a = "abc"
}
Which is considered correct by
./gradlew detekt
Is this a known/intended behaviour? Should I open an issue on this?
Pulling the
::Linechart
trick makes me think that
detekt
doesn't like my
{}
and parses the code incorrectly
e

ephemient

06/04/2022, 6:00 PM
detekt-formatting simply wraps ktlint
and that looks like this #ktlint bug: https://github.com/pinterest/ktlint/issues/1330
Detekt 1.19.0→1.20.0 upgrades ktlint 0.42.1→0.45.2, which should have that issue fixed. what versions are you using?
g

gammax

06/04/2022, 7:15 PM
+1 to what @ephemient said
l

LeoColman

06/04/2022, 7:44 PM
id("io.gitlab.arturbosch.detekt") version "1.21.0-RC1"
Maybe I didn't upgrade the ktlint dependency, let me check
Plugin is 1.21, but
detektPlugin
was 1.19
I'll change that version too and check that again, but it probably will be fixed
2 Views