mirror of
https://github.com/jlengrand/detekt.git
synced 2026-03-10 08:11:23 +00:00
Show groovy and kotlin dsl in the same page (#2971)
* add goorvy and kotlin gradle in the documentation * Improve docs * Enable jekyll-redirect-from
This commit is contained in:
@@ -1,3 +1,6 @@
|
||||
source "https://rubygems.org"
|
||||
|
||||
gem 'github-pages', group: :jekyll_plugins
|
||||
group :jekyll_plugins do
|
||||
gem 'github-pages'
|
||||
gem 'jekyll-redirect-from'
|
||||
end
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
GEM
|
||||
remote: https://rubygems.org/
|
||||
specs:
|
||||
activesupport (6.0.3.1)
|
||||
activesupport (6.0.3.2)
|
||||
concurrent-ruby (~> 1.0, >= 1.0.2)
|
||||
i18n (>= 0.7, < 2)
|
||||
minitest (~> 5.1)
|
||||
@@ -16,9 +16,9 @@ GEM
|
||||
colorator (1.1.0)
|
||||
commonmarker (0.17.13)
|
||||
ruby-enum (~> 0.5)
|
||||
concurrent-ruby (1.1.6)
|
||||
dnsruby (1.61.3)
|
||||
addressable (~> 2.5)
|
||||
concurrent-ruby (1.1.7)
|
||||
dnsruby (1.61.4)
|
||||
simpleidn (~> 0.1)
|
||||
em-websocket (0.5.1)
|
||||
eventmachine (>= 0.12.9)
|
||||
http_parser.rb (~> 0.6.0)
|
||||
@@ -28,7 +28,7 @@ GEM
|
||||
execjs (2.7.0)
|
||||
faraday (1.0.1)
|
||||
multipart-post (>= 1.2, < 3)
|
||||
ffi (1.12.2)
|
||||
ffi (1.13.1)
|
||||
forwardable-extended (2.6.0)
|
||||
gemoji (3.0.1)
|
||||
github-pages (207)
|
||||
@@ -81,7 +81,7 @@ GEM
|
||||
octokit (~> 4.0)
|
||||
public_suffix (~> 3.0)
|
||||
typhoeus (~> 1.3)
|
||||
html-pipeline (2.12.3)
|
||||
html-pipeline (2.14.0)
|
||||
activesupport (>= 2)
|
||||
nokogiri (>= 1.4)
|
||||
http_parser.rb (0.6.0)
|
||||
@@ -208,7 +208,7 @@ GEM
|
||||
jekyll-seo-tag (~> 2.1)
|
||||
minitest (5.14.1)
|
||||
multipart-post (2.1.1)
|
||||
nokogiri (1.10.9)
|
||||
nokogiri (1.10.10)
|
||||
mini_portile2 (~> 2.4.0)
|
||||
octokit (4.18.0)
|
||||
faraday (>= 0.9)
|
||||
@@ -233,6 +233,8 @@ GEM
|
||||
sawyer (0.8.2)
|
||||
addressable (>= 2.3.5)
|
||||
faraday (> 0.8, < 2.0)
|
||||
simpleidn (0.1.1)
|
||||
unf (~> 0.1.4)
|
||||
terminal-table (1.8.0)
|
||||
unicode-display_width (~> 1.1, >= 1.1.1)
|
||||
thread_safe (0.3.6)
|
||||
@@ -240,14 +242,18 @@ GEM
|
||||
ethon (>= 0.9.0)
|
||||
tzinfo (1.2.7)
|
||||
thread_safe (~> 0.1)
|
||||
unf (0.1.4)
|
||||
unf_ext
|
||||
unf_ext (0.0.7.7)
|
||||
unicode-display_width (1.7.0)
|
||||
zeitwerk (2.3.0)
|
||||
zeitwerk (2.4.0)
|
||||
|
||||
PLATFORMS
|
||||
ruby
|
||||
|
||||
DEPENDENCIES
|
||||
github-pages
|
||||
jekyll-redirect-from
|
||||
|
||||
BUNDLED WITH
|
||||
1.17.3
|
||||
|
||||
@@ -103,6 +103,9 @@ defaults:
|
||||
sidebars:
|
||||
- mydoc_sidebar
|
||||
|
||||
plugins:
|
||||
- jekyll-redirect-from
|
||||
|
||||
description: "Meet detekt, a static code analysis tool for Kotlin."
|
||||
# the description is used in the feed.xml file
|
||||
|
||||
|
||||
@@ -38,11 +38,8 @@ entries:
|
||||
- title: with the Command Line Interface
|
||||
url: /cli.html
|
||||
output: web
|
||||
- title: with Gradle Groovy DSL
|
||||
url: /groovydsl.html
|
||||
output: web
|
||||
- title: with Gradle Kotlin DSL
|
||||
url: /kotlindsl.html
|
||||
- title: with Gradle
|
||||
url: /gradle.html
|
||||
output: web
|
||||
- title: with Gradle Plain Task
|
||||
url: /gradletask.html
|
||||
|
||||
@@ -37,8 +37,7 @@ This will create one baseline file per Gradle module.
|
||||
As this might not be the desired behavior for a multi module project, think about implementing
|
||||
a custom meta baseline task:
|
||||
|
||||
Gradle-DSL
|
||||
|
||||
###### Groovy DSL
|
||||
```groovy
|
||||
subprojects {
|
||||
detekt {
|
||||
@@ -61,11 +60,9 @@ task detektProjectBaseline(type: io.gitlab.arturbosch.detekt.DetektCreateBaselin
|
||||
exclude("**/resources/**")
|
||||
exclude("**/build/**")
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
Kotlin-DSL
|
||||
|
||||
###### Kotlin DSL
|
||||
```kotlin
|
||||
subprojects {
|
||||
detekt {
|
||||
@@ -88,7 +85,6 @@ val detektProjectBaseline by tasks.registering(DetektCreateBaselineTask::class)
|
||||
exclude("**/resources/**")
|
||||
exclude("**/build/**")
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
#### FAQ
|
||||
|
||||
@@ -214,12 +214,20 @@ For example `detekt` itself provides a wrapper over [ktlint](https://github.com/
|
||||
custom `formatting` rule set.
|
||||
To enable it, we add the published dependency to `detekt` via the `detektPlugins` configuration:
|
||||
|
||||
###### Groovy DSL
|
||||
```groovy
|
||||
dependencies {
|
||||
detektPlugins "io.gitlab.arturbosch.detekt:detekt-formatting:{{ site.detekt_version }}"
|
||||
}
|
||||
```
|
||||
|
||||
###### Kotlin DSL
|
||||
```kotlin
|
||||
dependencies {
|
||||
detektPlugins("io.gitlab.arturbosch.detekt:detekt-formatting:{{ site.detekt_version }}")
|
||||
}
|
||||
```
|
||||
|
||||
##### Pitfalls
|
||||
|
||||
- By default all rules not marked with `@active` in their `KDoc` are disabled.
|
||||
|
||||
@@ -2,8 +2,11 @@
|
||||
title: "Run detekt using the Detekt Gradle Plugin"
|
||||
keywords: detekt static analysis code kotlin
|
||||
sidebar:
|
||||
permalink: groovydsl.html
|
||||
permalink: gradle.html
|
||||
folder: gettingstarted
|
||||
redirect_from:
|
||||
- /groovydsl.html
|
||||
- /kotlindsl.html
|
||||
summary:
|
||||
---
|
||||
|
||||
@@ -21,15 +24,16 @@ The detekt Gradle plugin will generate multiple tasks
|
||||
- `detektGenerateConfig` - Generates a default detekt configuration file into your project directory.
|
||||
- `detektBaseline` - Similar to `detekt`, but creates a code smell baseline. Further detekt runs will only feature new smells not in this list.
|
||||
- `detektIdeaFormat` - Uses a local `idea` installation to format your Kotlin (and other) code according to the specified `code-style.xml`.
|
||||
- `detektIdeaInspect` Uses a local `idea` installation to run inspections on your Kotlin (and other) code according to the specified `inspections.xml` profile.
|
||||
- `detektIdeaInspect` - Uses a local `idea` installation to run inspections on your Kotlin (and other) code according to the specified `inspections.xml` profile.
|
||||
|
||||
Use the Groovy or Kotlin DSL of Gradle to apply the detekt Gradle Plugin. You can further configure the Plugin
|
||||
using the detekt closure as described [here](#closure).
|
||||
|
||||
##### <a name="gradlegroovy">Configuration when using Groovy DSL</a>
|
||||
##### <a name="gradle">Configuration</a>
|
||||
|
||||
Using the plugins DSL:
|
||||
|
||||
###### Groovy DSL
|
||||
```groovy
|
||||
plugins {
|
||||
id "io.gitlab.arturbosch.detekt" version "{{ site.detekt_version }}"
|
||||
@@ -51,8 +55,31 @@ repositories {
|
||||
}
|
||||
```
|
||||
|
||||
###### Kotlin DSL
|
||||
```kotlin
|
||||
plugins {
|
||||
id("io.gitlab.arturbosch.detekt").version("{{ site.detekt_version }}")
|
||||
}
|
||||
|
||||
repositories {
|
||||
jcenter()
|
||||
|
||||
// or
|
||||
|
||||
mavenCentral()
|
||||
jcenter {
|
||||
content {
|
||||
// just allow to include kotlinx projects
|
||||
// detekt needs 'kotlinx-html' for the html report
|
||||
includeGroup("org.jetbrains.kotlinx")
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Using legacy plugin application (`buildscript{}`):
|
||||
|
||||
###### Groovy DSL
|
||||
```groovy
|
||||
buildscript {
|
||||
repositories {
|
||||
@@ -81,12 +108,42 @@ repositories {
|
||||
}
|
||||
```
|
||||
|
||||
###### Kotlin DSL
|
||||
```kotlin
|
||||
buildscript {
|
||||
repositories {
|
||||
gradlePluginPortal()
|
||||
}
|
||||
dependencies {
|
||||
classpath("io.gitlab.arturbosch.detekt:detekt-gradle-plugin:{{ site.detekt_version }}")
|
||||
}
|
||||
}
|
||||
|
||||
apply(plugin = "io.gitlab.arturbosch.detekt")
|
||||
|
||||
repositories {
|
||||
jcenter()
|
||||
|
||||
// or
|
||||
|
||||
mavenCentral()
|
||||
jcenter {
|
||||
content {
|
||||
// just allow to include kotlinx projects
|
||||
// detekt needs 'kotlinx-html' for the html report
|
||||
includeGroup("org.jetbrains.kotlinx")
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
##### <a name="gradleandroid">Configuration for Android projects</a>
|
||||
|
||||
When using Android make sure to have detekt configured in the project level build.gradle file.
|
||||
|
||||
You can configure the plugin in the same way as indicated above.
|
||||
|
||||
###### Groovy DSL
|
||||
```groovy
|
||||
buildscript {
|
||||
repositories {
|
||||
@@ -118,11 +175,17 @@ repositories {
|
||||
}
|
||||
```
|
||||
|
||||
###### Kotlin DSL
|
||||
```kotlin
|
||||
// TODO
|
||||
```
|
||||
|
||||
##### <a name="closure">Options for detekt configuration closure</a>
|
||||
|
||||
###### Groovy DSL
|
||||
```groovy
|
||||
detekt {
|
||||
toolVersion = "{{ site.detekt_version }}" // Version of the Detekt CLI that will be used. When unspecified the latest detekt version found will be used. Override to stay on the same version.
|
||||
toolVersion = "{{ site.detekt_version }}" // Version of Detekt that will be used. When unspecified the latest detekt version found will be used. Override to stay on the same version.
|
||||
input = files( // The directories where detekt looks for source files. Defaults to `files("src/main/java", "src/main/kotlin")`.
|
||||
"src/main/kotlin",
|
||||
"gensrc/main/kotlin"
|
||||
@@ -155,21 +218,66 @@ detekt {
|
||||
}
|
||||
```
|
||||
|
||||
###### Kotlin DSL
|
||||
```kotlin
|
||||
detekt {
|
||||
toolVersion = "{{ site.detekt_version }}" // Version of Detekt that will be used. When unspecified the latest detekt version found will be used. Override to stay on the same version.
|
||||
input = files("src/main/java", "src/main/kotlin") // The directories where detekt looks for source files. Defaults to `files("src/main/java", "src/main/kotlin")`.
|
||||
parallel = false // Builds the AST in parallel. Rules are always executed in parallel. Can lead to speedups in larger projects. `false` by default.
|
||||
config = files("path/to/config.yml") // Define the detekt configuration(s) you want to use. Defaults to the default detekt configuration.
|
||||
buildUponDefaultConfig = false // Interpret config files as updates to the default config. `false` by default.
|
||||
baseline = file("path/to/baseline.xml") // Specifying a baseline file. All findings stored in this file in subsequent runs of detekt.
|
||||
disableDefaultRuleSets = false // Disables all default detekt rulesets and will only run detekt with custom rules defined in plugins passed in with `detektPlugins` configuration. `false` by default.
|
||||
debug = false // Adds debug output during task execution. `false` by default.
|
||||
ignoreFailures = false // If set to `true` the build does not fail when the maxIssues count was reached. Defaults to `false`.
|
||||
reports {
|
||||
xml {
|
||||
enabled = true // Enable/Disable XML report (default: true)
|
||||
destination = file("build/reports/detekt.xml") // Path where XML report will be stored (default: `build/reports/detekt/detekt.xml`)
|
||||
}
|
||||
html {
|
||||
enabled = true // Enable/Disable HTML report (default: true)
|
||||
destination = file("build/reports/detekt.html") // Path where HTML report will be stored (default: `build/reports/detekt/detekt.html`)
|
||||
}
|
||||
txt {
|
||||
enabled = true // Enable/Disable TXT report (default: true)
|
||||
destination = file("build/reports/detekt.txt") // Path where TXT report will be stored (default: `build/reports/detekt/detekt.txt`)
|
||||
}
|
||||
custom {
|
||||
reportId = "CustomJsonReport" // The simple class name of your custom report.
|
||||
destination = file("build/reports/detekt.json") // Path where report will be stored
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
##### Using Type Resolution
|
||||
|
||||
Type resolution is experimental and works only for predefined `detektMain` and `detektTest` tasks or when implementing a
|
||||
custom detekt task with the `classpath` and `jvmTarget` properties present.
|
||||
|
||||
###### Groovy DSL
|
||||
```groovy
|
||||
tasks.detekt.jvmTarget = "1.8"
|
||||
```
|
||||
|
||||
###### Kotlin DSL
|
||||
```kotlin
|
||||
tasks {
|
||||
withType<Detekt> {
|
||||
// Target version of the generated JVM bytecode. It is used for type resolution.
|
||||
this.jvmTarget = "1.8"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
##### <a name="excluding">Leveraging Gradle's SourceTask - Excluding and including source files</a>
|
||||
|
||||
A detekt task extends the Gradle `SourceTask` to be only scheduled when watched source files are changed.
|
||||
It also allows to match files that should be excluded from the analysis.
|
||||
To do this introduce a query on detekt tasks and define include and exclude patterns outside the detekt closure:
|
||||
|
||||
###### Groovy DSL
|
||||
```groovy
|
||||
detekt {
|
||||
...
|
||||
@@ -181,13 +289,24 @@ tasks.withType(io.gitlab.arturbosch.detekt.Detekt) {
|
||||
}
|
||||
```
|
||||
|
||||
###### Kotlin DSL
|
||||
```kotlin
|
||||
detekt {
|
||||
...
|
||||
}
|
||||
|
||||
tasks.withType<io.gitlab.arturbosch.detekt.Detekt> {
|
||||
// include("**/special/package/**") // only analyze a sub package inside src/main/kotlin
|
||||
exclude("**/special/package/internal/**") // but exclude our legacy internal package
|
||||
}
|
||||
```
|
||||
|
||||
##### <a name="customdetekttask">Defining custom detekt task</a>
|
||||
|
||||
Custom tasks for alternative configurations or different source sets can be defined by creating a custom task that
|
||||
uses the type `Detekt`.
|
||||
|
||||
###### Groovy DSL
|
||||
|
||||
```groovy
|
||||
task detektFailFast(type: io.gitlab.arturbosch.detekt.Detekt) {
|
||||
description = "Runs a failfast detekt build."
|
||||
@@ -207,6 +326,26 @@ task detektFailFast(type: io.gitlab.arturbosch.detekt.Detekt) {
|
||||
}
|
||||
```
|
||||
|
||||
###### Kotlin DSL
|
||||
```kotlin
|
||||
task<io.gitlab.arturbosch.detekt.Detekt>("detektFailFast") {
|
||||
description = "Runs a failfast detekt build."
|
||||
source = files("src/main/kotlin", "src/test/kotlin")
|
||||
config = files("$rootDir/config.yml")
|
||||
debug = true
|
||||
reports {
|
||||
xml {
|
||||
destination = file("build/reports/failfast.xml")
|
||||
}
|
||||
html.destination = file("build/reports/failfast.html")
|
||||
}
|
||||
include("**/*.kt")
|
||||
include("**/*.kts")
|
||||
exclude("resources/")
|
||||
exclude("build/")
|
||||
}
|
||||
```
|
||||
|
||||
##### <a name="check-lifecycle">Disabling detekt from the check task</a>
|
||||
|
||||
Detekt tasks by default are verification tasks. They get executed whenever the Gradle check task gets executed.
|
||||
@@ -215,7 +354,13 @@ This aligns with the behavior of other code analysis plugins for Gradle.
|
||||
If you are adding detekt to an already long running project you may want to increase the code quality incrementally and therefore
|
||||
exclude detekt from the check task.
|
||||
|
||||
###### Groovy DSL
|
||||
```groovy
|
||||
// TODO
|
||||
```
|
||||
|
||||
###### Kotlin DSL
|
||||
```kotlin
|
||||
tasks.getByName("check") {
|
||||
this.setDependsOn(this.dependsOn.filterNot {
|
||||
it is TaskProvider<*> && it.name == "detekt"
|
||||
@@ -11,6 +11,7 @@ summary:
|
||||
2. Run `gradle detekt`
|
||||
3. Add `check.dependsOn detekt` if you want to run _detekt_ on every `build`
|
||||
|
||||
###### Groovy DSL
|
||||
```groovy
|
||||
repositories {
|
||||
jcenter()
|
||||
@@ -45,3 +46,8 @@ dependencies {
|
||||
detekt 'io.gitlab.arturbosch.detekt:detekt-cli:{{ site.detekt_version }}'
|
||||
}
|
||||
```
|
||||
|
||||
###### Kotlin DSL
|
||||
```kotlin
|
||||
// TODO
|
||||
```
|
||||
|
||||
@@ -1,162 +0,0 @@
|
||||
---
|
||||
title: "Run detekt using Gradle Kotlin DSL"
|
||||
keywords: detekt static analysis code kotlin
|
||||
sidebar:
|
||||
permalink: kotlindsl.html
|
||||
folder: gettingstarted
|
||||
summary:
|
||||
---
|
||||
|
||||
All information from Gradle Groovy DSL are still valid, but the
|
||||
DSL to apply the plugin changes slightly.
|
||||
|
||||
##### <a name="gradlekotlin">Configuration when using Kotlin DSL</a>
|
||||
|
||||
Using the plugins DSL:
|
||||
|
||||
```kotlin
|
||||
plugins {
|
||||
id("io.gitlab.arturbosch.detekt").version("{{ site.detekt_version }}")
|
||||
}
|
||||
|
||||
repositories {
|
||||
jcenter()
|
||||
|
||||
// or
|
||||
|
||||
mavenCentral()
|
||||
jcenter {
|
||||
content {
|
||||
// just allow to include kotlinx projects
|
||||
// detekt needs 'kotlinx-html' for the html report
|
||||
includeGroup("org.jetbrains.kotlinx")
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Using legacy plugin application (`buildscript{}`):
|
||||
|
||||
```kotlin
|
||||
buildscript {
|
||||
repositories {
|
||||
gradlePluginPortal()
|
||||
}
|
||||
dependencies {
|
||||
classpath("io.gitlab.arturbosch.detekt:detekt-gradle-plugin:{{ site.detekt_version }}")
|
||||
}
|
||||
}
|
||||
|
||||
apply(plugin = "io.gitlab.arturbosch.detekt")
|
||||
|
||||
repositories {
|
||||
jcenter()
|
||||
|
||||
// or
|
||||
|
||||
mavenCentral()
|
||||
jcenter {
|
||||
content {
|
||||
// just allow to include kotlinx projects
|
||||
// detekt needs 'kotlinx-html' for the html report
|
||||
includeGroup("org.jetbrains.kotlinx")
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
##### <a name="closure">Options for detekt configuration closure</a>
|
||||
|
||||
```kotlin
|
||||
detekt {
|
||||
toolVersion = "{{ site.detekt_version }}" // Version of the Detekt CLI that will be used. When unspecified the latest detekt version found will be used. Override to stay on the same version.
|
||||
input = files("src/main/java", "src/main/kotlin") // The directories where detekt looks for source files. Defaults to `files("src/main/java", "src/main/kotlin")`.
|
||||
parallel = false // Builds the AST in parallel. Rules are always executed in parallel. Can lead to speedups in larger projects. `false` by default.
|
||||
config = files("path/to/config.yml") // Define the detekt configuration(s) you want to use. Defaults to the default detekt configuration.
|
||||
buildUponDefaultConfig = false // Interpret config files as updates to the default config. `false` by default.
|
||||
baseline = file("path/to/baseline.xml") // Specifying a baseline file. All findings stored in this file in subsequent runs of detekt.
|
||||
disableDefaultRuleSets = false // Disables all default detekt rulesets and will only run detekt with custom rules defined in plugins passed in with `detektPlugins` configuration. `false` by default.
|
||||
debug = false // Adds debug output during task execution. `false` by default.
|
||||
ignoreFailures = false // If set to `true` the build does not fail when the maxIssues count was reached. Defaults to `false`.
|
||||
reports {
|
||||
xml {
|
||||
enabled = true // Enable/Disable XML report (default: true)
|
||||
destination = file("build/reports/detekt.xml") // Path where XML report will be stored (default: `build/reports/detekt/detekt.xml`)
|
||||
}
|
||||
html {
|
||||
enabled = true // Enable/Disable HTML report (default: true)
|
||||
destination = file("build/reports/detekt.html") // Path where HTML report will be stored (default: `build/reports/detekt/detekt.html`)
|
||||
}
|
||||
txt {
|
||||
enabled = true // Enable/Disable TXT report (default: true)
|
||||
destination = file("build/reports/detekt.txt") // Path where TXT report will be stored (default: `build/reports/detekt/detekt.txt`)
|
||||
}
|
||||
custom {
|
||||
reportId = "CustomJsonReport" // The simple class name of your custom report.
|
||||
destination = file("build/reports/detekt.json") // Path where report will be stored
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
##### Using Type Resolution
|
||||
|
||||
Type resolution is experimental and works only for predefined `detektMain` and `detektTest` tasks or when implementing a
|
||||
custom detekt task with the `classpath` and `jvmTarget` properties present.
|
||||
|
||||
```kotlin
|
||||
tasks {
|
||||
withType<Detekt> {
|
||||
// Target version of the generated JVM bytecode. It is used for type resolution.
|
||||
this.jvmTarget = "1.8"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
##### <a name="excluding">Leveraging Gradle's SourceTask - Excluding and including source files</a>
|
||||
|
||||
A detekt task extends the Gradle `SourceTask` to be only scheduled when watched source files are changed.
|
||||
It also allows to match files that should be excluded from the analysis.
|
||||
To do this introduce a query on detekt tasks and define include and exclude patterns outside the detekt closure:
|
||||
|
||||
```kotlin
|
||||
detekt {
|
||||
...
|
||||
}
|
||||
|
||||
tasks.withType<io.gitlab.arturbosch.detekt.Detekt> {
|
||||
// include("**/special/package/**") // only analyze a sub package inside src/main/kotlin
|
||||
exclude("**/special/package/internal/**") // but exclude our legacy internal package
|
||||
}
|
||||
```
|
||||
|
||||
##### <a name="customdetekttask">Defining custom detekt task</a>
|
||||
|
||||
Custom tasks for alternative configurations or different source sets can be defined by creating a custom task that
|
||||
uses the type `Detekt`.
|
||||
|
||||
###### Kotlin DSL
|
||||
```kotlin
|
||||
task<io.gitlab.arturbosch.detekt.Detekt>("detektFailFast") {
|
||||
description = "Runs a failfast detekt build."
|
||||
source = files("src/main/kotlin", "src/test/kotlin")
|
||||
config = files("$rootDir/config.yml")
|
||||
debug = true
|
||||
reports {
|
||||
xml {
|
||||
destination = file("build/reports/failfast.xml")
|
||||
}
|
||||
html.destination = file("build/reports/failfast.html")
|
||||
}
|
||||
include("**/*.kt")
|
||||
include("**/*.kts")
|
||||
exclude("resources/")
|
||||
exclude("build/")
|
||||
}
|
||||
```
|
||||
|
||||
##### <a name="idea">Integrating detekt inside your IntelliJ IDEA</a>
|
||||
|
||||
detekt comes with an [IntelliJ Plugin](https://plugins.jetbrains.com/plugin/10761-detekt) that you can install directly from the IDE. The plugin offers warning highlight directly inside the IDE as well as support for code formatting.
|
||||
|
||||
The source code of the plugin is available here: [detekt/detekt-intellij-plugin](https://github.com/detekt/detekt-intellij-plugin)
|
||||
Reference in New Issue
Block a user