ktlint

An anti-bikeshedding Kotlin linter with built-in formatter.

Version

0.36.0

Runtime

OpenJDK 8

Supported Languages

Kotlin

Official Documentation

https://ktlint.github.io/

YAML Configuration

ktlint:

  • input:

    Patterns to include in reports.

  • ignore:

    Patterns to exclude from reports.

  • auto-fix:

    true/false

    Note: As of now, ktlint does not keep CRLF line endings and all EOL characters are converted to LF in files where the auto-fix is applied. We will solve this problem, but for the time being, please don't enable the auto-fix feature if you need to keep CRLF line endings.

    Note: --limit option is not applied in auto-fix mode.

  • config-file:

    Alias of --editorconfig option.

  • machine:

    • cpu:

      Amount of CPU. The default machine has 0.5 CPU with 1920 MiB RAM.

  • options:

    -a, --android              Turn on Android Kotlin Style Guide compatibility
        --disabled_rules=<disabledRules>
                               Comma-separated list of rules to globally disable
        --limit=<limit>        Maximum number of errors to show (default: show all)
    -R, --ruleset=<rulesets>   A path to a JAR file containing additional ruleset(s)
        --skip-classpath-check  Do not check classpath for potential conflicts
        --editorconfig=<editorConfigPath>
                               Path to .editorconfig
        --experimental         Enabled experimental rules (ktlint-ruleset-experimental)
    
  • thresholds:

    • num-issues:

      No tool specific severity levels are available.

  • experimental:

    • incremental:

      true/false

      Note: The incremental analysis is disabled if any kinds of configuration files are changed. The files recognized as configuration files are as follows:

      • Configuration files:
        • **/.editorconfig
      • Rule files:
        • Files specified to -R, --ruleset options

YAML Examples

  • With default options:

    inspecode:
      ktlint: default
    
  • With enabling auto-fixing and default options:

    inspecode:
      ktlint: auto-fix
    
  • With custom machine:

    inspecode:
      ktlint:
        machine:
          cpu: 1.5 # 1.5 CPU, 5760 MiB RAM
    
  • With custom options:

    inspecode:
      ktlint:
        options:
          --limit: 10
    
  • With a configuration file:

    inspecode:
      ktlint:
        config-file: ./my/.editorconfig
    

    The above configuration is equivalent to:

    inspecode:
      ktlint:
        options:
          --editorconfig: ./my/.editorconfig
    

Configuration File Detection

If no configuration files are specified via config-file or options field, Inspecode lets ktlint find configuration files in your repository.

results matching ""

    No results matching ""