Kotlin lint (klint) 적용
Kotlin lint (klint) 적용
https://pinterest.github.io/ktlint/
kotlin lint를 적용하는 방법중에 klint라는 것이 있어서 정리해보려고 한다.
plugins {
...
id("org.jlleitschuh.gradle.ktlint") version "10.2.1" // 추가
}
// project.gradle
apply(plugin = "org.jlleitschuh.gradle.ktlint")
gradle.properties
kotlin.code.style=official
.editconfig
disabled_rules=no-wildcard-imports
## Coding conventions
### Kotlin Coding convention
The Kotlin camp provides a coding convention officially provided by Jetbrain. The project is based on the [Kotlin Coding Convention](https://kotlinlang.org/docs/coding-conventions.html).
If you set the `gradle.properties` file as shown below, the code style is automatically set to the Kotlin official convention.
```properties
kotlin.code.style=official
Editorconfig
EditorConfig provides the ability to define and manage code styles at the directory level
- ktlint recognizes and uses
.editorconfigfiles - As the default value may change as the ktlint version increases, it is recommended to explicitly define the default value in
.editorconfig - You can even define rules not specified in the official Kotlin coding conventions
If you are curious about the details, please go to the link
Gradle Tasks
Ktlint
You can easily use tasks through jlleitschuh/ktlint-gradle plugin.
Code style check
Check the code style
./gradlew ktlintCheck
Code formatting
You can batch convert code styles
```shell ./gradlew ktlintFormat
이 기사는 저작권자의 CC BY 4.0 라이센스를 따릅니다.