v

    voben

    2 years ago
    I can’t seem to get autocorrect to work. This is what my detekt.gradle file looks like. Any ideas?
    apply plugin: 'io.gitlab.arturbosch.detekt'
    
    detekt {
        parallel = true
        config = files("$rootDir/codeQuality/detekt.yml")
        autoCorrect = true
        reports {
            xml {
                enabled = false
            }
            txt {
                enabled = false
            }
        }
    }
    c

    chao

    2 years ago
    Did you run
    ./gradlew detekt --auto-correct
    ?
    v

    voben

    2 years ago
    When I run
    ./gradlew detekt --auto-correct
    I get Unknown command-line option ‘--auto-correct’
    Is that the same thing?
    c

    chao

    2 years ago
    https://detekt.github.io/detekt/extensions.html#autocorrect-property According to the doc, it should work at least with both options on
    Note that only the ktlint rules actually support autocorrect
    v

    voben

    2 years ago
    But why doesnt the auto correction option work when I run it with gradle? I just get the error above
    Got it working by moving detekt configuration from detekt.gradle to a build.gradle file with detekt closure. Thanks
    c

    chao

    2 years ago
    Does that mean that detekt.gradle was not applied in the build.gradle before 🤔
    v

    voben

    2 years ago
    So did some more digging, it looks like every rule I want formatted, I have to add the autoCorrect: truenode. Autocorrect doesnt seem to work when placed only the build.gradle file
    c

    chao

    2 years ago
    Ah yes
    v

    voben

    2 years ago
    But if I want all rules autoCorrected, it doesnt look like I can have this just once like this. I still need to add autoCorrect to each individual formatting rule. That right?
    formatting:
      autoCorrect: true
    c

    chao

    2 years ago
    By default those have autoCorrect = true
    v

    voben

    2 years ago
    Thanks @chao