【问题标题】:How to generate and use a detekt baseline using the maven plugin?如何使用 maven 插件生成和使用 detekt 基线?
【发布时间】:2020-01-17 16:51:59
【问题描述】:

我正在尝试在使用 Kotlin 和 detekt-maven-plugin 的多模块 Maven 项目中使用 detekt。

按照找到here 的说明生成包含现有问题的基线,我尝试运行:

mvn detekt:cb -Ddetekt.debug=true

然而,这似乎不会产生提到的baseline.xml 文件。

【问题讨论】:

    标签: maven kotlin detekt


    【解决方案1】:

    原来baseline生成时必须指定baseline文件名:

    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值降低到合适的值。

    【讨论】:

    • detekt-maven-plugin 没有现有的标签,所以也许有更高代表的人可以添加一个。
    猜你喜欢
    • 1970-01-01
    • 2016-08-31
    • 2012-04-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-10-04
    • 2014-12-05
    • 2014-12-01
    相关资源
    最近更新 更多