Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Disable autoCorrect property for all rules if global flag is set to f…
…alse (#2413) * Fix max line length issues for readability * Disable autoCorrect property for all rules if global flag is set to false - #2341 This way we make sure no KtFile is modified and our reporting calculates the right issue locations.
- Loading branch information
1 parent
3481ae7
commit b513df4
Showing
15 changed files
with
239 additions
and
14 deletions.
There are no files selected for viewing
23 changes: 23 additions & 0 deletions
23
...api/src/main/kotlin/io/gitlab/arturbosch/detekt/api/internal/DisabledAutoCorrectConfig.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package io.gitlab.arturbosch.detekt.api.internal | ||
|
||
import io.gitlab.arturbosch.detekt.api.Config | ||
import io.gitlab.arturbosch.detekt.api.Notification | ||
|
||
@Suppress("UNCHECKED_CAST") | ||
class DisabledAutoCorrectConfig(val wrapped: Config) : Config, ValidatableConfiguration { | ||
|
||
override fun subConfig(key: String): Config = DisabledAutoCorrectConfig(wrapped.subConfig(key)) | ||
|
||
override fun <T : Any> valueOrDefault(key: String, default: T): T = when (key) { | ||
"autoCorrect" -> false as T | ||
else -> wrapped.valueOrDefault(key, default) | ||
} | ||
|
||
override fun <T : Any> valueOrNull(key: String): T? = when (key) { | ||
"autoCorrect" -> false as T | ||
else -> wrapped.valueOrNull(key) | ||
} | ||
|
||
override fun validate(baseline: Config, excludePatterns: Set<Regex>): List<Notification> = | ||
validateConfig(wrapped, baseline, excludePatterns) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
detekt-cli/src/test/resources/configs/config-with-auto-correct.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
style: | ||
autoCorrect: true | ||
MagicNumber: | ||
autoCorrect: true | ||
MagicString: | ||
autoCorrect: false | ||
|
||
comments: | ||
autoCorrect: false | ||
ClassDoc: | ||
autoCorrect: true | ||
FunctionDoc: | ||
autoCorrect: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
...o.gitlab.arturbosch.detekt.api.internal/-disabled-auto-correct-config/-init-.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
--- | ||
title: DisabledAutoCorrectConfig.<init> - detekt-api | ||
--- | ||
|
||
[detekt-api](../../index.html) / [io.gitlab.arturbosch.detekt.api.internal](../index.html) / [DisabledAutoCorrectConfig](index.html) / [<init>](./-init-.html) | ||
|
||
# <init> | ||
|
||
`DisabledAutoCorrectConfig(wrapped: `[`Config`](../../io.gitlab.arturbosch.detekt.api/-config/index.html)`)` |
25 changes: 25 additions & 0 deletions
25
...io.gitlab.arturbosch.detekt.api.internal/-disabled-auto-correct-config/index.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
--- | ||
title: DisabledAutoCorrectConfig - detekt-api | ||
--- | ||
|
||
[detekt-api](../../index.html) / [io.gitlab.arturbosch.detekt.api.internal](../index.html) / [DisabledAutoCorrectConfig](./index.html) | ||
|
||
# DisabledAutoCorrectConfig | ||
|
||
`class DisabledAutoCorrectConfig : `[`Config`](../../io.gitlab.arturbosch.detekt.api/-config/index.html)`, `[`ValidatableConfiguration`](../-validatable-configuration/index.html) | ||
|
||
### Constructors | ||
|
||
| [<init>](-init-.html) | `DisabledAutoCorrectConfig(wrapped: `[`Config`](../../io.gitlab.arturbosch.detekt.api/-config/index.html)`)` | | ||
|
||
### Properties | ||
|
||
| [wrapped](wrapped.html) | `val wrapped: `[`Config`](../../io.gitlab.arturbosch.detekt.api/-config/index.html) | | ||
|
||
### Functions | ||
|
||
| [subConfig](sub-config.html) | Tries to retrieve part of the configuration based on given key.`fun subConfig(key: `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`): `[`Config`](../../io.gitlab.arturbosch.detekt.api/-config/index.html) | | ||
| [validate](validate.html) | `fun validate(baseline: `[`Config`](../../io.gitlab.arturbosch.detekt.api/-config/index.html)`, excludePatterns: `[`Set`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-set/index.html)`<`[`Regex`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.text/-regex/index.html)`>): `[`List`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-list/index.html)`<`[`Notification`](../../io.gitlab.arturbosch.detekt.api/-notification/index.html)`>` | | ||
| [valueOrDefault](value-or-default.html) | Retrieves a sub configuration or value based on given key. If configuration property cannot be found the specified default value is returned.`fun <T : `[`Any`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)`> valueOrDefault(key: `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`, default: T): T` | | ||
| [valueOrNull](value-or-null.html) | Retrieves a sub configuration or value based on given key. If the configuration property cannot be found, null is returned.`fun <T : `[`Any`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)`> valueOrNull(key: `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`): T?` | | ||
|
12 changes: 12 additions & 0 deletions
12
...tlab.arturbosch.detekt.api.internal/-disabled-auto-correct-config/sub-config.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
--- | ||
title: DisabledAutoCorrectConfig.subConfig - detekt-api | ||
--- | ||
|
||
[detekt-api](../../index.html) / [io.gitlab.arturbosch.detekt.api.internal](../index.html) / [DisabledAutoCorrectConfig](index.html) / [subConfig](./sub-config.html) | ||
|
||
# subConfig | ||
|
||
`fun subConfig(key: `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`): `[`Config`](../../io.gitlab.arturbosch.detekt.api/-config/index.html) | ||
|
||
Tries to retrieve part of the configuration based on given key. | ||
|
9 changes: 9 additions & 0 deletions
9
...gitlab.arturbosch.detekt.api.internal/-disabled-auto-correct-config/validate.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
--- | ||
title: DisabledAutoCorrectConfig.validate - detekt-api | ||
--- | ||
|
||
[detekt-api](../../index.html) / [io.gitlab.arturbosch.detekt.api.internal](../index.html) / [DisabledAutoCorrectConfig](index.html) / [validate](./validate.html) | ||
|
||
# validate | ||
|
||
`fun validate(baseline: `[`Config`](../../io.gitlab.arturbosch.detekt.api/-config/index.html)`, excludePatterns: `[`Set`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-set/index.html)`<`[`Regex`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.text/-regex/index.html)`>): `[`List`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-list/index.html)`<`[`Notification`](../../io.gitlab.arturbosch.detekt.api/-notification/index.html)`>` |
13 changes: 13 additions & 0 deletions
13
...rturbosch.detekt.api.internal/-disabled-auto-correct-config/value-or-default.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
--- | ||
title: DisabledAutoCorrectConfig.valueOrDefault - detekt-api | ||
--- | ||
|
||
[detekt-api](../../index.html) / [io.gitlab.arturbosch.detekt.api.internal](../index.html) / [DisabledAutoCorrectConfig](index.html) / [valueOrDefault](./value-or-default.html) | ||
|
||
# valueOrDefault | ||
|
||
`fun <T : `[`Any`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)`> valueOrDefault(key: `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`, default: T): T` | ||
|
||
Retrieves a sub configuration or value based on given key. If configuration property cannot be found | ||
the specified default value is returned. | ||
|
13 changes: 13 additions & 0 deletions
13
...b.arturbosch.detekt.api.internal/-disabled-auto-correct-config/value-or-null.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
--- | ||
title: DisabledAutoCorrectConfig.valueOrNull - detekt-api | ||
--- | ||
|
||
[detekt-api](../../index.html) / [io.gitlab.arturbosch.detekt.api.internal](../index.html) / [DisabledAutoCorrectConfig](index.html) / [valueOrNull](./value-or-null.html) | ||
|
||
# valueOrNull | ||
|
||
`fun <T : `[`Any`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)`> valueOrNull(key: `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`): T?` | ||
|
||
Retrieves a sub configuration or value based on given key. | ||
If the configuration property cannot be found, null is returned. | ||
|
9 changes: 9 additions & 0 deletions
9
....gitlab.arturbosch.detekt.api.internal/-disabled-auto-correct-config/wrapped.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
--- | ||
title: DisabledAutoCorrectConfig.wrapped - detekt-api | ||
--- | ||
|
||
[detekt-api](../../index.html) / [io.gitlab.arturbosch.detekt.api.internal](../index.html) / [DisabledAutoCorrectConfig](index.html) / [wrapped](./wrapped.html) | ||
|
||
# wrapped | ||
|
||
`val wrapped: `[`Config`](../../io.gitlab.arturbosch.detekt.api/-config/index.html) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.