Skip to content

Commit

Permalink
Breaking: Remove Detekt. Please use their own Gradle Plugin.
Browse files Browse the repository at this point in the history
  • Loading branch information
vanniktech committed Aug 24, 2024
1 parent 79f9a86 commit dfdbac4
Show file tree
Hide file tree
Showing 9 changed files with 3 additions and 460 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ POM_ARTIFACT_ID=gradle-code-quality-tools-plugin
POM_NAME=Gradle Code Quality Tools Plugin
POM_PACKAGING=jar

POM_DESCRIPTION=Gradle plugin that generates Checkstyle, PMD, CPD, Lint, Detekt & Ktlint Tasks for every subproject.
POM_DESCRIPTION=Gradle plugin that generates Checkstyle, PMD, CPD, Lint & Ktlint Tasks for every subproject.
POM_INCEPTION_YEAR=2016

POM_URL=http://github.com/vanniktech/gradle-code-quality-tools-plugin/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
@file:Suppress("Detekt.TooManyFunctions", "UnstableApiUsage")

package com.vanniktech.code.quality.tools

import com.android.build.gradle.BaseExtension
Expand Down Expand Up @@ -47,7 +45,6 @@ class CodeQualityToolsPlugin : Plugin<Project> {
project.addKtlint(rootProject, extension)
project.addKotlin(extension)
project.addCpd(extension)
project.addDetekt(rootProject, extension)
project.addLint(extension)
}
}
Expand Down Expand Up @@ -143,7 +140,6 @@ fun Project.addCheckstyle(rootProject: Project, extension: CodeQualityToolsPlugi
return false
}

@Suppress("Detekt.ComplexMethod")
fun Project.addLint(extension: CodeQualityToolsPluginExtension): Boolean {
val isNotIgnored = !shouldIgnore(extension)
val isEnabled = extension.lint.enabled
Expand Down Expand Up @@ -297,52 +293,6 @@ fun Project.addCpd(extension: CodeQualityToolsPluginExtension): Boolean {
return false
}

fun Project.addDetekt(rootProject: Project, extension: CodeQualityToolsPluginExtension): Boolean {
val isNotIgnored = !shouldIgnore(extension)
val isEnabled = extension.detekt.enabled
val isDetektSupported = isKotlinProject()

if (isNotIgnored && isEnabled && isDetektSupported) {
val detektConfiguration = configurations.create("detekt") { configuration ->
configuration.attributes {
it.attribute(Usage.USAGE_ATTRIBUTE, objects.named(Usage::class.javaObjectType, Usage.JAVA_RUNTIME))
}

configuration.isCanBeConsumed = false
configuration.isVisible = false

configuration.defaultDependencies {
it.add(dependencies.create("io.gitlab.arturbosch.detekt:detekt-cli:${extension.detekt.toolVersion}"))
}
}

tasks.register("detektCheck", DetektCheckTask::class.java) { task ->
task.failFast = extension.detekt.failFast
task.buildUponDefaultConfig = extension.detekt.buildUponDefaultConfig
task.parallel = extension.detekt.parallel
task.version = extension.detekt.toolVersion
task.outputDirectory = layout.buildDirectory.dir("reports/detekt/")
task.configFile = rootProject.file(extension.detekt.config)
task.inputFile = file(extension.detekt.input)
task.classpath.from(detektConfiguration)
task.inputs.files(kotlinFiles(baseDir = extension.detekt.input))

task.inputs.property("baseline-file-exists", false)

extension.detekt.baselineFileName?.let {
val file = file(it)
task.baselineFilePath = file.toString()
task.inputs.property("baseline-file-exists", file.exists())
}
}

tasks.named(CHECK_TASK_NAME).configure { it.dependsOn("detektCheck") }
return true
}

return false
}

private fun Project.shouldIgnore(extension: CodeQualityToolsPluginExtension) = extension.ignoreProjects.contains(name)

private fun Project.isJavaProject(): Boolean {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,6 @@ open class CodeQualityToolsPluginExtension @Inject constructor(
val ktlint = objectFactory.newInstance(KtlintExtension::class.java)
fun ktlint(action: Action<in KtlintExtension>) = action.execute(ktlint)

val detekt = objectFactory.newInstance(DetektExtension::class.java)
fun detekt(action: Action<in DetektExtension>) = action.execute(detekt)

val cpd = objectFactory.newInstance(CpdExtension::class.java)
fun cpd(action: Action<in CpdExtension>) = action.execute(cpd)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,5 @@ open class CpdExtension {
* A positive integer indicating the minimum token count to trigger a CPD match.
* @since 0.6.0
*/
@Suppress("Detekt.MagicNumber") // Will be fixed with RC12.
var minimumTokenCount: Int = 50
}
143 changes: 0 additions & 143 deletions src/main/kotlin/com/vanniktech/code/quality/tools/DetektCheckTask.kt

This file was deleted.

This file was deleted.

Loading

0 comments on commit dfdbac4

Please sign in to comment.