An open API service indexing awesome lists of open source software.

https://github.com/hanggrian/rulebook

Aggresive multi-platform linter extensions
https://github.com/hanggrian/rulebook

checkstyle ktlint lint-rules

Last synced: 2 months ago
JSON representation

Aggresive multi-platform linter extensions

Awesome Lists containing this project

README

          

[![GitHub Actions](https://img.shields.io/github/actions/workflow/status/hanggrian/rulebook/code-analysis.yml)](https://github.com/hanggrian/rulebook/actions/workflows/code-analysis.yml)
[![Codecov](https://img.shields.io/codecov/c/gh/hanggrian/rulebook)](https://app.codecov.io/gh/hanggrian/rulebook/)
[![Renovate](https://img.shields.io/badge/dependency-mend-blue)](https://developer.mend.io/github/hanggrian/rulebook/) \
[![Maven Central](https://img.shields.io/maven-central/v/com.hanggrian.rulebook/rulebook-ktlint)](https://repo1.maven.org/maven2/com/hanggrian/rulebook/rulebook-ktlint/)
[![Java](https://img.shields.io/badge/java-8+-informational)](https://docs.oracle.com/javase/8/) \
[![Package Index](https://shields.io/pypi/v/rulebook-pylint)](https://pypi.org/project/rulebook-pylint/)
[![Package Index Test](https://shields.io/pypi/v/rulebook-pylint?label=testpypi&pypiBaseUrl=https://test.pypi.org)](https://test.pypi.org/project/rulebook-pylint/)
[![Python](https://img.shields.io/badge/python-3.10+-informational)](https://docs.python.org/3.10/)

# Rulebook

![The Rulebook logo.](https://github.com/hanggrian/rulebook/raw/assets/logo.svg)

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](https://github.com/checkstyle/checkstyle/) | [Sun Java Style](https://checkstyle.sourceforge.io/sun_style.html) or
[Google Java Style Guide](https://google.github.io/styleguide/javaguide.html)
Groovy | [CodeNarc](https://github.com/CodeNarc/CodeNarc/) | [Groovy Style Guide](https://groovy-lang.org/style-guide.html)
Kotlin | [Ktlint](https://github.com/pinterest/ktlint/) | [Ktlint Official Style](https://pinterest.github.io/ktlint/1.0.1/rules/code-styles/)
C/C++ | [Cppcheck](https://github.com/danmar/cppcheck/) | [C++ Core Guidelines](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines) or
[Google C++ Style Guide](https://google.github.io/styleguide/cppguide.html)
Python | [Pylint](https://github.com/pylint-dev/pylint/) | [Pylint Style](https://pylint.pycqa.org/en/latest/user_guide/configuration/all-options.html) or
[Google Python Style Guide](https://google.github.io/styleguide/pyguide.html)
JavaScript | [ESLint](https://github.com/eslint/eslint/) | [Crockford Code Conventions](https://www.crockford.com/code.html) or
[Google JavaScript Style Guide](https://google.github.io/styleguide/jsguide.html)
TypeScript | [typescript-eslint](https://github.com/typescript-eslint/typescript-eslint/) | [Crockford Code Conventions](https://www.crockford.com/code.html) or
[Google TypeScript Style Guide](https://google.github.io/styleguide/tsguide.html)

[View all rules](https://hanggrian.github.io/rulebook/rules/)

## Download

### Maven

```gradle
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

```sh
pip install regex pylint rulebook-pylint
pip install regex cppcheck rulebook-cppcheck
```

### NPM

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

## Usage

### Checkstyle

- Apply [Checkstyle Gradle Plugin](https://docs.gradle.org/current/userguide/checkstyle_plugin.html).
- Using configuration `checkstyle`, add this project as dependency.
- Point to local config file or put in `/config/checkstyle/codenarc.xml`.

```gradle
plugins {
checkstyle
}

checkstyle {
toolVersion "$checkstyleVersion"
configFile "path/to/rulebook_checkstyle.xml"
}

dependencies {
checkstyle "com.hanggrian.rulebook:rulebook-checkstyle:$libraryVersion"
}
```

### CodeNarc

- Apply [CodeNarc Gradle Plugin](https://docs.gradle.org/current/userguide/codenarc_plugin.html).
- Using configuration `codenarc`, add this project as dependency.
- Point to local config file or put in `/config/codenarc/codenarc.xml`.

```gradle
plugins {
codenarc
}

codenarc {
toolVersion "$codenarcVersion"
configFile "path/to/rulebook_codenarc.xml"
}

dependencies {
codenarc "com.hanggrian.rulebook:rulebook-codenarc:$libraryVersion"
}
```

### Ktlint

- Apply [Ktlint Integration](https://pinterest.github.io/ktlint/0.49.1/install/integrations/#custom-gradle-integration)
to Gradle project.
- Using configuration `ktlint`, add this project as dependency.

```gradle
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](https://pinterest.github.io/ktlint/0.49.1/rules/configuration-intellij-idea/),
using standard [Kotlin coding conventions](https://kotlinlang.org/docs/coding-conventions.html)
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](https://github.com/google/google-java-format/):

- In **File > Settings > Editor > Code Style > Java**, import
[IntelliJ Java Google Style file](https://raw.githubusercontent.com/google/styleguide/gh-pages/intellij-java-google-style.xml).