Manuel Lorenzo
08/01/2023, 10:00 AMapply plugin: 'io.gitlab.arturbosch.detekt'
def projectSource = file(projectDir)
def configFile = files("${rootProject.projectDir}/config/detekt/detekt.yml")
def baselineFile = file("${rootProject.projectDir}/config/detekt/baseline.xml")
def kotlinFiles = "**/*.kt"
def resourceFiles = "**/resources/**"
def buildFiles = "**/build/**"
tasks.register("detektAll", Detekt) {
description = "Custom DETEKT build for all modules"
parallel = true
ignoreFailures = false
autoCorrect = false
buildUponDefaultConfig = true
setSource(projectSource)
baseline.set(baselineFile)
config.setFrom(configFile)
include(kotlinFiles)
exclude(resourceFiles, buildFiles)
reports {
html.required.set(true)
xml.required.set(false)
txt.required.set(false)
}
}
And I have a dependency on the detekt plugin formatting detektPlugins(libs.detekt.formatting)
. However when I run the task with ./gradlew detektAll --auto-correct
or ./gradlew detektAll -PdetektAutoFix=true
I'm getting errors such as:
./gradlew detektAll --auto-correct
Configuration on demand is an incubating feature.
> Task :detektAll FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':detektAll'.
> java.lang.IllegalStateException: Analyzing /Users/myuser/Developer/myandroidapp/app/src/test/java/package/uk/presentation/screens/TagsInputProcessorTest.kt led to an exception.
Location: java.base/java.util.concurrent.CompletableFuture.encodeThrowable(CompletableFuture.java:315)
The original exception message was: java.lang.IllegalArgumentException: Stack should be empty:
IndentContext(fromASTNode=Element(kotlin.FILE), toASTNode=PsiWhiteSpace, nodeIndent=, firstChildIndent=, childIndent=, lastChildIndent=, activated=true)
IndentContext(fromASTNode=Element(CLASS), toASTNode=PsiElement(RBRACE), nodeIndent=, firstChildIndent=, childIndent=, lastChildIndent=, activated=false)
IndentContext(fromASTNode=Element(CLASS_BODY), toASTNode=PsiElement(RBRACE), nodeIndent=, firstChildIndent= , childIndent= , lastChildIndent=, activated=false)
IndentContext(fromASTNode=PsiElement(LBRACE), toASTNode=PsiElement(RBRACE), nodeIndent=, firstChildIndent=, childIndent= , lastChildIndent=, activated=true)
IndentContext(fromASTNode=BLOCK, toASTNode=PsiElement(RBRACE), nodeIndent= , firstChildIndent= , childIndent= , lastChildIndent= , activated=false)
IndentContext(fromASTNode=Element(FUN), toASTNode=PsiElement(RPAR), nodeIndent= , firstChildIndent=, childIndent=, lastChildIndent=, activated=true)
IndentContext(fromASTNode=BLOCK, toASTNode=PsiElement(RBRACE), nodeIndent= , firstChildIndent= , childIndent= , lastChildIndent= , activated=false)
IndentContext(fromASTNode=Element(FUN), toASTNode=PsiElement(RPAR), nodeIndent= , firstChildIndent=, childIndent=, lastChildIndent=, activated=true)
IndentContext(fromASTNode=BLOCK, toASTNode=PsiElement(RBRACE), nodeIndent= , firstChildIndent= , childIndent= , lastChildIndent= , activated=false)
IndentContext(fromASTNode=Element(FUN), toASTNode=PsiElement(RPAR), nodeIndent= , firstChildIndent=, childIndent=, lastChildIndent=, activated=true)
IndentContext(fromASTNode=BLOCK, toASTNode=PsiElement(RBRACE), nodeIndent= , firstChildIndent= , childIndent= , lastChildIndent= , activated=false)
IndentContext(fromASTNode=Element(FUN), toASTNode=PsiElement(RPAR), nodeIndent= , firstChildIndent=, childIndent=, lastChildIndent=, activated=true)
Running detekt '1.23.0' on Java '17.0.6+10' on OS 'Mac OS X'
If the exception message does not help, please feel free to create an issue on our GitHub page.
Travis Miehm
08/01/2023, 4:58 PMManuel Lorenzo
08/02/2023, 9:21 AMManuel Lorenzo
08/02/2023, 9:24 AMorg.gradle.parallel=false
and I'm still getting the sameManuel Lorenzo
08/02/2023, 9:25 AM