我通过执行以下命令生成了default.yml文件: ./gradlew detektGenerateConfig
./gradlew detektGenerateConfig
检查了一下: ./gradlew detektCheck
./gradlew detektCheck
插件发现了两个类型问题 TooGenericExceptionCaught , MaxLineLength 但不是我在代码中添加的未使用的导入,以查看detekt是否捕捉到它们。
TooGenericExceptionCaught
MaxLineLength
这些行在my default-detekt-config.yml中
NoUnusedImports: active: true autoCorrect: true
谢谢你的指点!
这个 NoUnusedImports
NoUnusedImports
dependencies { detekt "io.gitlab.arturbosch.detekt:detekt-formatting:[version]" }
或者,您也可以使用detekt规则来检测 UnusedImports 通过在 config.yml
UnusedImports
config.yml
UnusedImports: active: false