Skip to content
This repository has been archived by the owner on Feb 2, 2023. It is now read-only.

Experimental support for detekt as a Kotlin compiler plugin

Notifications You must be signed in to change notification settings

detekt/detekt-compiler-plugin

Repository files navigation

Detekt Compiler Plugin

Pre Merge Checks gradle plugin

⚠️ This repository is archived as the development of the detekt-compiler-plugin has been moved to the detekt repo ⚠️

Experimental support for integrating detekt as a Kotlin compiler plugin

image

Usage

plugins {
    id("io.github.detekt.gradle.compiler-plugin") version "0.4.0"
}

detekt {
    isEnabled = true // or with a property: System.getProperty("runDetekt") != null
    // everything from https://detekt.github.io/detekt/kotlindsl.html#options-for-detekt-configuration-closure
    // is supported to declare, only some options are used. See limitations. 
}

detekt plugins can be added to your project using the detektPlugins configuration:

dependencies {
    detektPlugins("io.gitlab.arturbosch.detekt:detekt-formatting:<version>")
}

Reports can be customized using the detekt extension which is added to KotlinCompile tasks. Using Groovy this might look like:

tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).configureEach {
    detekt {
        reports {
            xml.enabled.set(true)
            txt.enabled.set(false)
            create("custom") {
                enabled.set(false)
            }
        }
    }
}

Limitations

Everything our Gradle plugin (DetektExtension) supports, is also supported on the declaration side with this plugin.
However only the following options are implemented/passed down to detekt:

  • config
  • baseline
  • debug
  • buildUponDefaultConfig