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 729f322
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,11 @@ 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() }
.orElse(DEFAULT_AUTO_CORRECT_VALUE)
)
reportsDir.convention(
project.extensions.getByType(ReportingExtension::class.java).baseDirectory.dir("detekt")
)
Expand Down Expand Up @@ -118,3 +122,4 @@ class DetektBasePlugin : Plugin<Project> {
}

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

0 comments on commit 729f322

Please sign in to comment.