rulebook

Personal lint rules and code convention

View the Project on GitHub hendraanggrian/ruleboo

Travis CI Codecov Maven Central Nexus Snapshot OpenJDK

Rulebook

Additional third-party rules for lint tools, meant to be used in conjunction with official ones. Most of the rules are opinionated personal code style mandate. However, some already exists in other linters, providing the same experience across languages.

Language Linter Main Rules
Java Checkstyle Google Java Style Guide via Checkstyle Google Checks
Kotlin KtLint Kotlin coding conventions via KtLint standard rules

Download

repositories {
    mavenCentral()
}

dependencies {
    checkstyle "com.hendraanggrian.rulebook:rulebook-checkstyle:$version"
    ktlint "com.hendraanggrian.rulebook:rulebook-ktlint:$version"
}

Usage

Checkstyle

Apply Checkstyle Gradle Plugin. Using configuration checkstyle, add this project as dependency. Then use rulebook_checks.xml provided in sample-checkstyle or within rulebook-checkstyle jar.

plugins {
    checkstyle
}

checkstyle {
    toolVersion "$checkstyleVersion"
    configFile "path/to/rulebook_checks.xml"
    // the rest of checkstyle plugin configurations
}

dependencies {
    checkstyle "com.puppycrawl.tools:checkstyle:$checkstyleVersion"
    checkstyle "com.hendraanggrian.rulebook:rulebook-checkstyle:libraryVersion"
}

KtLint

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

configurations {
    ktlint
}

dependencies {
    ktlint "com.pinterest:ktlint:$ktlintVersion"
    ktlint "com.hendraanggrian.rulebook:rulebook-ktlint:libraryVersion"
}

// the rest of ktlint tasks' configuration

Do not use KtLint with Spotless, as there is yet no way to add custom rules.

First time installation

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

Checkstyle

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

KtLint

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