Skip to content

Commit

Permalink
Allow setting default autocorrect mode with Gradle property
Browse files Browse the repository at this point in the history
This makes it possible to enable autocorrect when running tasks that
depend on detekt tasks e.g. ./gradlew check
-Pdetekt.default.autocorrect=true

Without this, the only way to enable autocorrect on CLI is by declaring
every detekt task on the CLI and passing --auto-correct to every one.
  • Loading branch information
3flex committed Mar 12, 2024
1 parent 9403c84 commit bef771c
Showing 1 changed file with 2 additions and 2 deletions.
Expand Up @@ -39,7 +39,7 @@ class DetektBasePlugin : Plugin<Project> {
allRules.convention(DEFAULT_ALL_RULES_VALUE)
buildUponDefaultConfig.convention(DEFAULT_BUILD_UPON_DEFAULT_CONFIG_VALUE)
disableDefaultRuleSets.convention(DEFAULT_DISABLE_RULESETS_VALUE)
autoCorrect.convention(DEFAULT_AUTO_CORRECT_VALUE)
autoCorrect.convention(project.providers.gradleProperty(ENABLE_AUTOCORRECT).map { it.toBoolean() })
reportsDir.convention(
project.extensions.getByType(ReportingExtension::class.java).baseDirectory.dir("detekt")
)
Expand Down Expand Up @@ -107,7 +107,6 @@ class DetektBasePlugin : Plugin<Project> {
private const val DEFAULT_IGNORE_FAILURES = false
private val DEFAULT_FAIL_ON_SEVERITY = FailOnSeverity.Error
private const val DEFAULT_PARALLEL_VALUE = false
private const val DEFAULT_AUTO_CORRECT_VALUE = false
private const val DEFAULT_DISABLE_RULESETS_VALUE = false
private const val DEFAULT_ALL_RULES_VALUE = false
private const val DEFAULT_BUILD_UPON_DEFAULT_CONFIG_VALUE = false
Expand All @@ -118,3 +117,4 @@ class DetektBasePlugin : Plugin<Project> {
}

internal const val CONFIGURATION_DETEKT_PLUGINS = "detektPlugins"
internal const val ENABLE_AUTOCORRECT = "detekt.default.autocorrect"

0 comments on commit bef771c

Please sign in to comment.