maarten ha
05/02/2025, 12:03 PMtasks {
withType<io.gitlab.arturbosch.detekt.Detekt> {
parallel = true
config.setFrom(files("/config/detekt/detekt.yml"))
buildUponDefaultConfig = true
jvmTarget = "$projectJvmTarget"
autoCorrect = true
setSource(files("src/main/kotlin", "src/test/kotlin"))
setOf(
"**/*.kt",
"**/*.kts",
".*/resources/.*",
".*/build/.*",
"/versions.gradle.kts",
).forEach {
include(it)
}
reports {
html.required.set(true)
html.outputLocation.set(file("reports/detekt/detekt.html"))
sarif.required.set(true)
sarif.outputLocation.set(file("reports/detekt/detekt.sarif"))
}
outputs.dir("reports/detekt/")
}
}
dependencies {
...
detektPlugins("io.gitlab.arturbosch.detekt:detekt-formatting:1.23.8")
}
For the detekt config I just ran the generate config task. Have not changed anything in ithfhbd
05/15/2025, 8:29 AMOleksandr Balan
06/11/2025, 10:08 AMErnestas
06/19/2025, 5:48 AMbuild.gradle
does not see the task - detektMain
, only - detekt
is available. I can still run the detektMain
task manually without problems though.Maxime Michel
07/09/2025, 11:46 AMmy-project:
-> android
|-> androidApp (Android application module)
|-> other android specific modules
-> build-logic
|-> convention
|-> Detekt.kt (Detekt specific configurations are contained here)
|-> MultiplatformLibraryConventionPlugin.kt
-> ios (iOS application)
-> kmp
|-> data
|-> domain
|-> presentation
-> testing
|-> detekt
|-> konsist
This is a somewhat generic KMP project structure I think (but this works without issues so I'm not planning on changing this structure).
The contents of the :testing:detekt
module is attached as an image.
I followed the documentation and updated my Detekt.kt
file to apply (or so I thought) the new rule I created:
internal fun Project.configureDetekt() {
configure<DetektExtension> {
source.from(files("$projectDir/src"))
config.from(files(
"$rootDir/config/quality/detekt/detekt-config.yml",
"$rootDir/testing/detekt/src/main/resources/config/config.yml",
))
baseline = file("$rootDir/config/quality/detekt/baseline.xml")
autoCorrect = true
}
tasks.withType<Detekt> {
exclude("**/test/")
exclude(".*/tmp/.*")
dependsOn(":testing:detekt:assemble")
}
dependencies {
CONFIGURATION_DETEKT_PLUGINS(libs.findLibrary("detekt.cli").get())
CONFIGURATION_DETEKT_PLUGINS(libs.findLibrary("detekt.formatting").get())
CONFIGURATION_DETEKT_PLUGINS(libs.findLibrary("detekt.libraries").get())
CONFIGURATION_DETEKT_PLUGINS(project(":testing:detekt"))
}
}
In my custom rule, I added an override for the visitKtFile
function that simply prints the file name but this does nothing and I see no logs when running the detekt task.Vanessa Johnson
07/14/2025, 1:19 PMEugen Martynov
07/14/2025, 2:02 PMAditya Bhaskar
07/14/2025, 5:17 PMUnusedPrivateMember
and NullableToStringCall
errors, and a few ISEs:
> A failure occurred while executing io.gitlab.arturbosch.detekt.invoke.DetektWorkAction
> java.lang.IllegalStateException: Analyzing something.kt led to an exception.
Location: java.base/java.util.concurrent.CompletableFuture.encodeThrowable(Unknown Source)
The original exception message was: java.lang.NullPointerException
Running detekt '1.23.8' on Java '21.0.6+-13391695-b895.109' on OS 'Mac OS X'
If the exception message does not help, please feel free to create an issue on our GitHub page.
Given this PR is still draft, is this to be expected?Rob
07/27/2025, 4:34 PMjuliocbcotta
08/05/2025, 2:11 PMprivate fun FSProductToAdd.toOrderPipeModel(): OPProductToAdd {
return OPProductToAdd(
productId = productId,
quantity = quantity
)
}
even thought that is called inside of the class...
I also got a bunch of RedundantSuspendModifier
private suspend fun register() = suspendCoroutine { cont ->
// do integration with callbacks from tracking library
}
also UnreachableCode
internal fun decodeJwt(token: String): JSONObject? {
var stringToDecode = (token.split('.').getOrNull(1) ?: return null)
.replace('-', '+')
.replace('_', '/')
@Suppress("MagicNumber")
when (stringToDecode.codePointCount(0, stringToDecode.lastIndex) % 4) {
2 -> stringToDecode += "=="
3 -> stringToDecode += '='
else -> {
// nothing to do
}
}
--> line 32 return try {
stringToDecode.decodeBase64()?.utf8()?.let(::JSONObject)
} catch (e: JSONException) {
Timber.e(e, "Tried to decode a JSON Web Token that is not JSON!")
null
}
}
saying JwtDecoder.kt:32:5: This expression is unreachable code which should either be used or removed. [UnreachableCode]
ursus
08/27/2025, 3:13 PMmax file lines
? (Can't find it)
That's something I presonally care more about than number of functions, lines per class etcsegunfamisa
09/01/2025, 12:33 PMMaximumLineLength
forbidden and the baseline updated
@Suppress("MaximumLineLength")
class Bar
If for any reason, I have to modify that suppress rule, to something like:
@Suppress("MaximumLineLength", "RandomOtherRule")
class Bar
This entire line is going to be reported despite the fact that a new rule suppression is introduced, and the "already known" issue was not changedRyan Ulep
09/03/2025, 1:01 PMseb
09/04/2025, 5:16 PMgammax
09/04/2025, 5:20 PMseb
09/04/2025, 5:36 PMseb
09/04/2025, 5:36 PMseb
09/04/2025, 5:36 PMseb
09/04/2025, 6:02 PMdetekt.autoCorrect
in Gradle also doesn't do auto-correct when I run :detekt
. Is there some other thing I need to do to enable auto-correct for the rule?eygraber
09/04/2025, 7:09 PMThere were 11 compiler errors found during legacy compiler analysis. This affects accuracy of reporting.Do I need to use the compiler plugin to resolve those?
gammax
09/04/2025, 7:10 PMNicholas Doglio
09/04/2025, 7:13 PMGama11
09/05/2025, 8:29 AMGama11
09/05/2025, 9:18 AMBrais Gabin
09/05/2025, 10:12 AMJoe
09/05/2025, 10:45 PMDownloading from central: <https://repo.maven.apache.org/maven2/dev/detekt/detekt-kotlin-analysis-api/2.0.0-alpha.0/detekt-kotlin-analysis-api-2.0.0-alpha.0.jar>
Downloading from central: <https://repo.maven.apache.org/maven2/dev/detekt/detekt-kotlin-analysis-api-standalone/2.0.0-alpha.0/detekt-kotlin-analysis-api-standalone-2.0.0-alpha.0.jar>
[.... snip reactor summary ...]
Execution detekt of goal org.apache.maven.plugins:maven-antrun-plugin:3.1.0:run failed: Plugin org.apache.maven.plugins:maven-antrun-plugin:3.1.0 or one of its dependencies could not be resolved: The following artifacts could not be resolved: dev.detekt:detekt-kotlin-analysis-api:jar:2.0.0-alpha.0 (absent), dev.detekt:detekt-kotlin-analysis-api-standalone:jar:2.0.0-alpha.0 (absent): Could not find artifact dev.detekt:detekt-kotlin-analysis-api:jar:2.0.0-alpha.0 in central (<https://repo.maven.apache.org/maven2>)
ursus
09/05/2025, 11:39 PMRyan Ulep
09/08/2025, 1:02 PMdetekt-compiler-plugin
should work with Kotlin 2.+ correct? I'm getting:
error: there are some plugins incompatible with language version 2.0:
io.github.detekt.compiler.plugin.DetektCompilerPluginRegistrar
Please use language version 1.9 or below
ursus
09/11/2025, 7:41 PMtype resolution
enabled?
If I run detektMain
I'm getting both debug & release. Is that normal? (and release stuff takes way longer)ursus
09/12/2025, 5:13 PMCognitiveComplexMethod
blows up.
Is there a global way to have implementations of such interface to not be analyzed?