https://kotlinlang.org logo
#detekt
Title
# detekt
s

sanogueralorenzo

11/09/2019, 1:24 AM
Managed to do the top level task that runs in around 20 seconds compared per module where it was taking 2 to 3 minutes. In my top level build gradle I ended up having
Copy code
plugins {
    id "io.gitlab.arturbosch.detekt" version "1.1.1"
}

dependencies {
    detektPlugins "io.gitlab.arturbosch.detekt:detekt-formatting:1.1.1"
}

task detektAll(type: io.gitlab.arturbosch.detekt.Detekt) {
    description = "Runs detekt for the entire project."

    input = files("$projectDir")
    config = files("$rootDir/config/detekt/detekt.yml")
    parallel = false
    includes = ["**/*.kt", "**/*.kts"]
    excludes = ["**/resources/**", "**/build/**", "**/buildSrc/**", "**/test/**/*.kt"]
    baseline = file("$rootDir/config/detekt/baseline.xml")
    reports {
        xml { enabled = false }
        html { enabled = false }
        txt { enabled = false }
    }
}
The detektFormat has
disableDefaultRuleSets
&
buildUponDefaultConfig
which I'm not sure if I should apply. Also noticed that there is no need for a detekt format task if you just set
autoCorrect
to true in the detektAll Only thing I find a bit confusing is that if it can fix all the issues it will fix them but still fail. While on ktlintFormat it would only fail if it is not able to fix any of the issues. The reason I say it is confusing is because I can have 5 issues that only 3 have been fixed but all will be marked as failure. Which leaves the developer in the situation to not know for which ones to look because some of them might have already been fixed. On the other hand for CI this is great because even if it is able to fix them it will fail and sends a clear message of: you have detektIssues run it locally, commit & push
👍 1
f

Frodrigues

11/09/2019, 11:52 AM
buildUponDefaultConfig
is when you change some rules in your detekt.yml and you don't want to put every rule
the
disableDefaultRuleSets
is when you don't want detekt to use the default rules and so you have to put every rule in your config file
m

Mike

11/09/2019, 2:30 PM
And on cli, there's a fail-fast flag that activates all rules and fails if anything isn't right. You then configure those rules you want different or off, and Suppress in code those that are false positives. So a few ways to work with it.
s

sanogueralorenzo

11/09/2019, 4:07 PM
Thanks everyone!
I want to try out the jar approach to compare time with the existing one.
2 Views