ashdavies
10/19/2024, 11:54 PMExecution failed for task ':app-launcher:common:detektAndroidRelease'.
> Provided path '' is empty.
ashdavies
10/19/2024, 11:54 PMashdavies
10/19/2024, 11:55 PMashdavies
10/21/2024, 11:23 PMdetektAll
depend on all Detekt
tasks, defining it as a new task of type Detekt
that takes the project source set seems to work betterFergus Hewson
10/24/2024, 7:22 AMLocation: java.base/java.util.concurrent.CompletableFuture.encodeThrowable(CompletableFuture.java:315)
The original exception message was: org.jetbrains.kotlin.com.intellij.psi.PsiInvalidElementAccessException: Element: class org.jetbrains.kotlin.com.intellij.psi.impl.source.tree.LeafPsiElement #kotlin because: different providers: org.jetbrains.kotlin.com.intellij.psi.DummyHolderViewProvider{vFile=LightVirtualFile: /DummyHolder, content=VirtualFileContent{size=0}, eventSystemEnabled=false}(3ecbbc63); org.jetbrains.kotlin.com.intellij.psi.SingleRootFileViewProvider{vFile=LightVirtualFile: /DummyHolder, content=VirtualFileContent{size=0}, eventSystemEnabled=true}(5e048bdd)
Atul Gupta
11/01/2024, 5:57 PMUnnecessaryLet
. If still reproducible can you create an issue in Detekt with the sample code?ralf
11/04/2024, 4:18 PMUndocumentedPublicFunction:
active: true
excludes: [
'**/src/**/*Component.kt',
]
Which excludes all classes with the Component
suffix. Now I’d like to exclude all inner classes with this suffix, too. I tried these two without success:
'**/src/**/*$Component.kt',
'**/src/**/*.Component.kt',
Any suggestion?Peter
11/14/2024, 12:25 PMPair
as return type 🤔Emil Kantis
11/20/2024, 12:06 PMJoão Silva
11/21/2024, 5:33 PMLongMethod
rule for @Composable
functions?
I've had the need to suppress it multiple times the more I write compose.
It can happen because of multiple lambdas, decision making, or any other reason.
Do you think it would be a good addition to change the current function to accept a new config like ignoredAnnotations
so that we can configure it? What are your toughts?
Thank you!Sebastian Schuberth
11/22/2024, 10:58 AMGMachine
11/24/2024, 1:42 PMAntonis Radz
11/26/2024, 4:42 PMtasks.withType<io.gitlab.arturbosch.detekt.Detekt> detekt@{
config.setFrom(files("$rootDir/detekt-config.yml"))
baseline.set(file("$rootDir/detekt-baseline.xml"))
setSource(files(rootDir))
include("**/*.kt")
exclude("**/*.kts")
exclude("**/resources/**")
exclude("**/build/**")
}
But this seems to be really slow, on CI it runs around 20mins, and project isn't big. Any ideas? Before CI was running around 5minsGMachine
11/27/2024, 2:55 PMproductArgs.favoriteLink!!.id
as UnnecessaryNotNullOperator
, even though productArgs.favoriteLink
is in another module and cannot be smart casted (Android Studio confirms this).
if (productArgs.favoriteLink != null) {
println(productArgs.favoriteLink!!.id) // Reported as UnnecessaryNotNullOperator
println(productArgs.favoriteLink.id) // Compiler error: smart cast not possible
}
Here’s how I resolve my classpath using a Gradle task:
tasks.register("resolveClasspath") {
def resolvedClasspath = providers.provider {
def classpathFiles = files()
// Iterate over application variants during the configuration phase
android.applicationVariants.all { variant ->
classpathFiles += variant.javaCompileProvider.get().classpath.filter { it.exists() }
}
// Convert classpath to a comma-separated string for later use
classpathFiles.files.collect { it.absolutePath }.join(",")
}
doLast {
println(resolvedClasspath.get())
}
}
Any ideas why Detekt might generate false positives in this setup? Am I missing something in my configuration? 🤔eygraber
11/27/2024, 8:21 PMarve
12/02/2024, 1:46 PMdetekt.yaml
?
(or even better, to the txt report)hfhbd
12/03/2024, 8:18 AMLouis
12/04/2024, 5:35 PMsubprojects {
apply {
plugin("io.gitlab.arturbosch.detekt")
}
detekt {
source.setFrom("src/main/kotlin", "src/main/java")
buildUponDefaultConfig = true
config.setFrom("$rootDir/detekt/config.yml")
baseline = file("$projectDir/detekt/baseline.xml")
autoCorrect = true
parallel = true
ignoreFailures = false
buildUponDefaultConfig = true
autoCorrect = true
ignoredBuildTypes = ["release", "benchmarkDebug", "benchmarkRelease"]
basePath = rootDir
}
dependencies {
detektPlugins("io.gitlab.arturbosch.detekt:detekt-formatting:1.23.7")
detektPlugins("io.nlopez.compose.rules:detekt:0.4.17")
}
}
Eric
01/21/2025, 3:25 PMfun foo() = "blah"
but I'd like to enforce that multi-line expression bodies have a line break after the =
or at least have it consistent within a single class/fileLouis
01/22/2025, 10:11 AMUnexpected error while running detekt analysis
io.gitlab.arturbosch.detekt.api.Config$InvalidConfigurationError: Provided configuration file is invalid: Structure must be from type Map<String,Any>!
while constructing a mapping
in reader, line 1, column 1:
build:
^
found duplicate key formatting
in reader, line 1056, column 1:
formatting:
^
Zsolt.bertalan
02/13/2025, 9:41 PMCzerwinskimarek88
02/14/2025, 8:56 AM<http://logger.info|logger.info> { "This is a very long logging message that exceeds the character limit, but I want Detekt to ignore it." }
I’ve tried various approaches, but I couldn’t find an in-built option to ignore specific function calls (like <http://logger.info|logger.info>
, logger.debug
, logger.warn
).
Is there a way to achieve this? Maybe there's a configuration option or a custom rule I could create?
Thanks in advance for your help! 🚀Brian Hartvigsen
02/21/2025, 6:53 PMMissingUseCall
rule detects the following as not using use
?
val code = """
fun <T> MyCloseable.useMe(block: (object) -> T) = use { block(this) }
fun MyCloseable.useMe() = use {}
fun test() {
MyCloseable(0).use {}
MyCloseable(1).useMe()
MyCloseable(2).useMe { it.doStuff() }
}
${myClosable(clazz)}
""".trimIndent()
These are obviously contrived, we have a pattern that would look more like:
MyCloseable(0).use { it.subPropertyClosable.use { sub -> sub.doStuff() } }
I was trying to shorthand that to something like the useMe
block except it's more like fun <T> MyCloseable.useMe(block: () -> T ) = use { subPropertyCloseable.use { block() } }
, but I get an error that MyCloseable
is doesn't call use
to access the Closeable
.Kim
02/24/2025, 3:48 AMrepo: local
as in the guides but would be nice to have some sensible default hooks support with .pre-commit-hooks.yaml
at the repo top level.eygraber
03/05/2025, 11:49 PMForbiddenMethodCall
value for tests instead of the whole rule?Max
03/21/2025, 3:44 PM@RequiresFullAnalysis
, but I don't see it in api. I use 1.23.8
version.
Has something changed? How can I use it?David Glasser
03/26/2025, 10:11 PMDoug McCluer
03/31/2025, 3:14 PMcontext(Activity)
fun finishWithContextReceiver(){
finish()
}
Håkon Pettersen
04/04/2025, 4:21 AM@Suppress("all")
like this:
ForbiddenSuppress:
active: true
rules: ["all", "CyclomaticComplexMethod"]
Currently, @Suppress("all")
isn't being caught, whereas "CyclomaticComplexMethod"
works as expected. Has anyone encountered this issue?
docs: https://detekt.dev/docs/rules/style/#forbiddensuppressmaarten 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 it