rulebook

Extended lint rules for Java, Groovy, and Kotlin

View the Project on GitHub hendraanggrian/ruleboo

Travis CI Codecov Maven Central Nexus Snapshot OpenJDK

Rulebook

Third-party rules for JVM-based 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 languages.

Language Linter Main Rules
Kotlin Ktlint Ktlint Official Style
Java Checkstyle Google Java Style
Groovy CodeNarc Groovy Style Guide

Download

repositories {
    mavenCentral()
}
dependencies {
    ktlint "com.hendraanggrian.rulebook:rulebook-ktlint:$version"
    checkstyle "com.hendraanggrian.rulebook:rulebook-checkstyle:$version"
    codenarc "com.hendraanggrian.rulebook:rulebook-codenarc:$version"
}

Usage

Ktlint

Apply Ktlint Integration to Gradle project. Using configuration ktlint, add this project as dependency.

configurations {
    ktlint
}
dependencies {
    ktlint "com.hendraanggrian.rulebook:rulebook-ktlint:$libraryVersion"
}
// the rest of ktlint tasks' configuration

Checkstyle

Apply Checkstyle Gradle Plugin. Using configuration checkstyle, add this project as dependency. Then, point config file to rulebook_checkstyle.xml.

plugins {
    checkstyle
}
checkstyle {
    toolVersion "$checkstyleVersion"
    configFile "path/to/rulebook_checkstyle.xml"
}
dependencies {
    checkstyle "com.hendraanggrian.rulebook:rulebook-checkstyle:$libraryVersion"
}

CodeNarc

Apply CodeNarc Gradle Plugin. Using configuration codenarc, add this project as dependency. Then, point config file to rulebook_codenarc.xml.

plugins {
    codenarc
}
codenarc {
    toolVersion "$codenarcVersion"
    configFile "path/to/rulebook_codenarc.xml"
}
dependencies {
    codenarc "com.hendraanggrian.rulebook:rulebook-codenarc:$libraryVersion"
}

First time installation

Presuming the IDE is IntelliJ IDEA, consider applying the linter style to it.

Ktlint

Explained in Ktlint IntelliJ IDEA Configuration, using standard Kotlin coding conventions is enough:

Checkstyle

In File > Settings > Editor > Code Style > Java, import IntelliJ Java Google Style file. The whole process are better explained in Google Java Format.