Skip to content

Latest commit

 

History

History
153 lines (111 loc) · 5.59 KB

File metadata and controls

153 lines (111 loc) · 5.59 KB

CircleCI Codecov
Maven Central Java
Package Index Package Index Test Python

Rulebook

The Rulebook logo.

Third-party linter rules for multiple programming languages. It aims to standardize existing rules from various linters, providing a consistent style across different languages and tools. It also serves as a reference for best practices in coding style.

Language Linter Styles
Java Checkstyle Sun Java Style or
Google Java Style Guide
Groovy CodeNarc Groovy Style Guide
Kotlin Ktlint Ktlint Official Style
C/C++ Cppcheck C++ Core Guidelines or
Google C++ Style Guide
Python Pylint Pylint Style or
Google Python Style Guide
JavaScript ESLint Crockford Code Conventions or
Google JavaScript Style Guide
TypeScript typescript-eslint Crockford Code Conventions or
Google TypeScript Style Guide

View all rules

Download

Maven

repositories {
    mavenCentral()
}

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

PyPI

pip install regex pylint rulebook-pylint
pip install regex cppcheck rulebook-cppcheck

NPM

npm install rulebook-eslint --save-dev
npm install rulebook-typescript-eslint --save-dev

Usage

Checkstyle

  • 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"
    }

CodeNarc

  • 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"
    }

Ktlint

  • 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

Cppcheck

Create addon.json file.

Pylint

Create .pylintrc file in the root directory.

ESLint

Create .eslint.config.js file in the root directory.

IDE settings

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

  1. Ktlint Style

    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 root gradle.properties.
  1. Google Java Style

    Explained in Google Java Format: