0
Android
detekt 1.19.0

运行此命令时,我得到以下输出,但没有因规则失败的类。

./gradlew detekt


37 kotlin files were analyzed.
Complexity Report:
        - 1,377 lines of code (loc)
        - 1,130 source lines of code (sloc)
        - 689 logical lines of code (lloc)
        - 19 comment lines of code (cloc)
        - 118 cyclomatic complexity (mcc)
        - 13 cognitive complexity
        - 0 number of total code smells
        - 1% comment source ratio
        - 171 mcc per 1,000 lloc
        - 0 code smells per 1,000 lloc

Project Statistics:
        - number of properties: 71
        - number of functions: 103
        - number of classes: 36
        - number of packages: 17
        - number of kt files: 37

Successfully generated SARIF: a standard format for the output of static analysis tools at /home/steve/androidProjects/Pokemon/app/build/reports/detekt/detekt.sarif
Successfully generated HTML report at /home/steve/androidProjects/Pokemon/app/build/reports/detekt/detekt.html
Successfully generated Checkstyle XML report at /home/steve/androidProjects/Pokemon/app/build/reports/detekt/detekt.xml
Successfully generated plain text report at /home/steve/androidProjects/Pokemon/app/build/reports/detekt/detekt.txt

但它并没有告诉我问题所在。

当我使用以下命令从android.yml文件中的 github 操作运行此命令时:

  - name: "Run detekt rules"
    uses: natiginfo/action-detekt-all@1.17.0

我将在我的 PR 上获得以下信息,这些信息为我提供了我正在寻找的信息。

complexity - 1h debt
    TooManyFunctions - 12/11 - [PokemonViewModel] at /github/workspace/app/src/main/java/me/androidbox/pokemon/presentation/viewmodels/PokemonViewModel.kt:22:7
    TooManyFunctions - 14/11 - [DependencyHandlerExtensions.kt] at /github/workspace/buildSrc/src/main/kotlin/DependencyHandlerExtensions.kt:1:1
    TooManyFunctions - 15/11 - [Dependencies.kt] at /github/workspace/buildSrc/src/main/kotlin/Dependencies.kt:1:1
naming - 15min debt
    MatchingDeclarationName - [ViewScope] at /github/workspace/app/src/main/java/me/androidbox/pokemon/di/scopes/PokemonScope.kt:5:1
    FunctionParameterNaming - [_isTransitive] at /github/workspace/buildSrc/src/main/kotlin/DependencyHandlerExtensions.kt:18:76
    FunctionNaming - [UITesting] at /github/workspace/buildSrc/src/main/kotlin/Dependencies.kt:195:23
style - 9h 5min debt

但是,我希望在本地运行时获得相同的信息,而不是等待 PR 在 github 操作上运行。

有没有办法从本地命令行执行此操作?

4

1 回答 1

0

我需要将此添加到我的顶级 gradle 构建文件中

subprojects {
    apply(plugin = "io.gitlab.arturbosch.detekt")

    detekt {
        config = files("${rootDir}/detekt.yml")

        allRules = true
        buildUponDefaultConfig = true

        reports {
        }
    }
}
于 2022-01-23T10:37:28.090 回答