如何使用 maven 插件生成和使用 detekt 基线?
How to generate and use a detekt baseline using the maven plugin?
我正在尝试在使用 Kotlin 的多模块 Maven 项目中使用 detekt detekt-maven-plugin。
按照找到的说明 here 生成现有问题的基线,我尝试了 运行:
mvn detekt:cb -Ddetekt.debug=true
然而,这似乎并没有生成提到的 baseline.xml
文件。
原来生成基线时必须指定基线文件名:
mvn detekt:cb -Ddetekt.baseline=baseline.xml
由于代码库已经有很多 detekt 发现的问题,我还必须使用自定义 detekt 配置文件并增加允许的问题数量 - 否则构建将失败并且根本不会生成基线.
总而言之,以下配置使其有效:
检测配置文件:
build:
maxIssues: 1000
生成基线后的插件配置:
<plugin>
<groupId>com.github.ozsie</groupId>
<artifactId>detekt-maven-plugin</artifactId>
<version>1.1.1</version>
<configuration>
<baseline>detekt-baseline.xml</baseline>
<config>detekt-config.yml</config>
<buildUponDefaultConfig>true</buildUponDefaultConfig>
</configuration>
<executions>
<execution>
<phase>verify</phase>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
生成基线后,可以将配置文件中的maxIssuses
值降低到合适的值。
我正在尝试在使用 Kotlin 的多模块 Maven 项目中使用 detekt detekt-maven-plugin。
按照找到的说明 here 生成现有问题的基线,我尝试了 运行:
mvn detekt:cb -Ddetekt.debug=true
然而,这似乎并没有生成提到的 baseline.xml
文件。
原来生成基线时必须指定基线文件名:
mvn detekt:cb -Ddetekt.baseline=baseline.xml
由于代码库已经有很多 detekt 发现的问题,我还必须使用自定义 detekt 配置文件并增加允许的问题数量 - 否则构建将失败并且根本不会生成基线.
总而言之,以下配置使其有效:
检测配置文件:
build:
maxIssues: 1000
生成基线后的插件配置:
<plugin>
<groupId>com.github.ozsie</groupId>
<artifactId>detekt-maven-plugin</artifactId>
<version>1.1.1</version>
<configuration>
<baseline>detekt-baseline.xml</baseline>
<config>detekt-config.yml</config>
<buildUponDefaultConfig>true</buildUponDefaultConfig>
</configuration>
<executions>
<execution>
<phase>verify</phase>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
生成基线后,可以将配置文件中的maxIssuses
值降低到合适的值。