Endre Deak
10/08/2021, 10:22 PMcmd+option+L
(I’m using a mac) to reformat kotlin code, I want this to match with the format kotlinter uses
• when I run a gradle build, kotlinter should format not only the changed code, but everything
• I want kotlinter result to be applied before detekt is executed (so for example if I have a long line, kotlinter fixes it, so detekt doesn’t fail on that)
From all things (idea, detekt, kotlinter) I’m using the latest versions:
• IDEA 2021.2.2 Ultimate (212.5284.40)
• detekt: 1.18.1
• kotlinter: 3.6.0
I always run into some problems:
• idea autoformat doesn’t match kotlinter format
• kotlinter only formats changed lines not the entire file
Relevant gradle parts:
plugins {
base
kotlin("jvm")
id("java")
id("idea")
id("com.google.cloud.tools.jib")
id("org.jmailen.kotlinter")
id("org.jetbrains.dokka")
id("io.gitlab.arturbosch.detekt")
`version-catalog`
application
}
detekt {
toolVersion = findProperty("detektVersion") as String
config = files("config/detekt/detekt.yml")
buildUponDefaultConfig = true
autoCorrect = true
debug = true
}
tasks.detekt {
dependsOn("formatKotlinMain")
}
// right now it's a single project, but might be a multiproject later
allprojects {
apply(plugin = "idea")
apply(plugin = "org.jmailen.kotlinter")
apply(plugin = "io.gitlab.arturbosch.detekt")
}
kotlinter {
ignoreFailures = false
indentSize = 4
reporters = arrayOf("checkstyle", "plain")
experimentalRules = false
}
gildor
10/10/2021, 2:49 PMEndre Deak
10/12/2021, 4:19 PM