/danger-checkstyle-plugin

Checkstyle plugin for Danger Kotlin will be available when Danger Kotlin using Kotlin 1.4 is released.

Primary LanguageKotlinApache License 2.0Apache-2.0

Coding Style Released Version

danger-checkstyle-plugin

A Danger Kotlin plugin for reporting checkstyle result.

Setup

  • Install Danger Kotlin
  • Add the following dependency in your Dangerfile.df.kts :
    @file:DependsOn("co.uzzu.danger.plugins:checkstyle:0.2.0")
  • Register plugin and then write script to report your checkstyle result.
    import co.uzzu.danger.plugins.checkstyle.CheckStyle
    import systems.danger.kotlin.Danger
    import systems.danger.kotlin.register
    
    register plugin CheckStyle
    
    // :

Examples

Simple use

@file:DependsOn("co.uzzu.danger.plugins:checkstyle:0.2.0")

import co.uzzu.danger.plugins.checkstyle.CheckStyle
import systems.danger.kotlin.Danger
import systems.danger.kotlin.register

register plugin CheckStyle

val d = Danger(args)

CheckStyle.report("path/to/checkstyle_result.xml")

Use with glob matcher

@file:DependsOn("co.uzzu.danger.plugins:checkstyle:0.2.0")

import co.uzzu.danger.plugins.checkstyle.CheckStyle
import systems.danger.kotlin.Danger
import systems.danger.kotlin.register

register plugin CheckStyle

val d = Danger(args)

CheckStyle.report("glob:**/path/to/*check_result.xml")

Use with configuration block

@file:DependsOn("co.uzzu.danger.plugins:checkstyle:0.2.0")

import co.uzzu.danger.plugins.checkstyle.CheckStyle
import systems.danger.kotlin.Danger
import systems.danger.kotlin.register

register plugin CheckStyle

val d = Danger(args)

CheckStyle.report {
    // Set configuration properties 
    // :

    // [Required] Set path to checkstyle result file.
    path = "path/to/checkstyle_result.xml"
}

Configuration

You can customize reporting styles as you needed by using configuration scope. The CheckStyle plugin object also has same properties, and these properties are used as default of configuration scope.

reporter

Determinate the reporting style. You can choose the following reporter.

Inline

Report as inline comment You can choose reporting method MESSAGE, WARN, and FAIL .

import co.uzzu.danger.plugins.checkstyle.Inline
import co.uzzu.danger.plugins.checkstyle.ReportMethod.*

CheckStyle.reporter = Inline // reporterMethod = ERROR is used by default.
CheckStyle.reporter = Inline { reportMethod = WARN }

Markdown

Report as message with the Markdown format.

import co.uzzu.danger.plugins.checkstyle.Markdown

CheckStyle.reporter = Markdown // label = "Checkstyle" is used by default.
CheckStyle.reporter = Markdown { label =  "My checkstyle" }

severities

Determinate list of the checkstyle severities(ERROR, IGNORE, INFO, WARNING ) to report. Only ERROR is reported by default.

import co.uzzu.danger.plugins.checkstyle.Severity.*

CheckStyle.severities = listOf(ERROR, IGNORE, INFO, WARNING)

basePath

Determinate base of check style result file path. The working directory is used by default.

CheckStyle.basePath = "path/to/your/base/directory"

License

Apache 2.0 License