Third-party rules for JVM and Python lint tools, meant to be used in conjunction with official ones. Most of the rules are opinionated personal code styles. However, some already exists in other linters, providing the same experience across multiple languages.
Language | Linter | Variants |
---|---|---|
Kotlin | Ktlint | Ktlint Style |
Java | Checkstyle | Sun Style or Google Java Style |
Groovy | CodeNarc | Groovy Style |
Python | Pylint | Pylint Style or Google Python Style |
repositories {
mavenCentral()
}
dependencies {
ktlint "com.hanggrian.rulebook:rulebook-ktlint:$version"
checkstyle "com.hanggrian.rulebook:rulebook-checkstyle:$version"
codenarc "com.hanggrian.rulebook:rulebook-codenarc:$version"
}
pip install pylint regex rulebook-pylint
- Apply Ktlint Integration to Gradle project.
- Using configuration
ktlint
, add this project as dependency.
configurations {
ktlint
}
dependencies {
ktlint "com.hanggrian.rulebook:rulebook-ktlint:$libraryVersion"
}
// the rest of ktlint tasks' configuration
- Apply Checkstyle Gradle Plugin.
- Using configuration
checkstyle
, add this project as dependency. - Point to local config file or put in
/config/checkstyle/codenarc.xml
.
plugins {
checkstyle
}
checkstyle {
toolVersion "$checkstyleVersion"
configFile "path/to/rulebook_checkstyle.xml"
}
dependencies {
checkstyle "com.hanggrian.rulebook:rulebook-checkstyle:$libraryVersion"
}
- Apply CodeNarc Gradle Plugin.
- Using configuration
codenarc
, add this project as dependency. - Point to local config file or put in
/config/codenarc/codenarc.xml
.
plugins {
codenarc
}
codenarc {
toolVersion "$codenarcVersion"
configFile "path/to/rulebook_codenarc.xml"
}
dependencies {
codenarc "com.hanggrian.rulebook:rulebook-codenarc:$libraryVersion"
}
- Point config file to local
pylintrc
.
Presuming the IDE is IntelliJ IDEA or PyCharm, consider applying the linter style to it.
Explained in Ktlint IntelliJ IDEA Configuration, using standard Kotlin coding conventions is enough:
- In File > Settings > Editor > Code Style > Kotlin, set from Kotlin style guide.
- Append
kotlin.code.style=official
to rootgradle.properties
.
Explained in Google Java Format:
- In File > Settings > Editor > Code Style > Java, import IntelliJ Java Google Style file.
Apply few changes in settings:
- In File > Settings > Editor > Code Style > Python > Blank Lines:
- Set After local imports and Before the first method to 0.
- Set the rest to 1.