ktlint

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

Version

0.30.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.

  • 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
        --limit=<limit>         Maximum number of errors to show (default: show
                                all)
        --repository=<repositories>
                                An additional Maven repository (Maven
                                Central/JCenter/JitPack are active by default)
                                (value format: <id>=<url>)
    -U, --repository-update     Check remote repositories for updated snapshots
    -R, --ruleset=<rulesets>    A path to a JAR file containing additional ruleset
                                (s) or a <groupId>:<artifactId>:<version>
                                triple pointing to a remote artifact (in which
                                case ktlint will first check local cache (~/.
                                m2/repository) and then, if not found, attempt
                                downloading it from Maven
                                Central/JCenter/JitPack/user-provided
                                repository)
        --skip-classpath-check  Do not check classpath for potential conflicts
        --editorconfig=<editorConfigPath>
                                Path to .editorconfig
    
  • 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 ""