Skip to content

marcospereira/kotlin-diktat-action

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

kotlin-diktat-action

This allows you to easily install and run diKTat in Kotlin projects.

Example usage

name: Run diKTat

on:
  push:
    branches: [ main ]

jobs:
  diktat:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: marcospereira/kotlin-diktat-action

Inputs

The action accepts inputs based on what diKTat CLI supports, but filters out a few options.

The supported inputs are:

  • patterns: A list of files to process by diktat

    • Default: "src/main/kotlin"
    • Examples:
      patterns: "src/main/kotlin src/test/kotlin src/functionalTest/kotlin"
      patterns: "src/**/*.kt"
  • config: specify the location of the YAML configuration file. By default, diktat-analysis.yml in the current directory is used

    • Default: "diktat-analysis.yml"
    • Examples:
      config: configs/diktat-analysis.yml
  • reporter: The reporter to use to log errors to output. Value should be one of checkstyle, html, json, plain, plain_group_by_file, sarif

    • Default: empty, meaning it will use the CLI's default (plain)
    • Examples:
      reporter: "html"
      output: diktat-report.html
      reporter: "sarif"
      output: diktat-report.sarif

      [!IMPORTANT] When setting a reporter, it is also required to set output, and diktat CLI fails if one is set but not the other.

  • output: Redirect the reporter output to a file. Must be provided when the reporter is provided

    • Default: empty
    • Examples: see reporter examples above.
  • group-by-file: A flag to group found errors by files

    • Default: "false"
    • Examples:
      group-by-file: true
  • log-level: Control the log level. Value should be one of error, warn, info, debug, trace

    • Default: "info"
    • Examples:
      log-level: "debug"
       log-level: "error"

A more complete example

name: Run diKTat

on:
  push:
    branches: [ main ]

jobs:
  diktat:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: marcospereira/kotlin-diktat-action
        with:
          patterns: "src/main/kotlin src/test/kotlin"
          log-level: debug
          group-by-file: true
          reporter: sarif
          output: diktat.sarif