What is Ktlint? is a static code analysis tool maintain by Pinterest. Linter and formatter for Kotlin code, more details here.

  1. Create a new file ktlint.gradle, and add below code:
repositories {
jcenter()
}

configurations {
ktlint
}

dependencies {
ktlint "com.pinterest:ktlint:0.36.0"
}

task ktlint(type: JavaExec, group: "verification") {
description = "Check Kotlin code style."
classpath = configurations.ktlint
main = "com.pinterest.ktlint.Main"
args "src/**/*.kt"
}

check.dependsOn ktlint

task ktlintFormat(type: JavaExec…