且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何配置 SpotBugs maven 插件以创建完整报告但仅检查高阈值?

更新时间:2023-09-29 23:20:34

不确定这是否有帮助,这主要是一种解决方法.

Not sure if that helps, it's mostly a workaround.

我有一个类似的案例,我所做的是将配置放在报告"标签(不是报告集)中.在build"标签中,我只放了插件信息和依赖项.配置使用输出 xml 和输出文件夹的默认值.我还添加了过滤掉一些错误的文件:

I have a similar case and what I did was that I placed the configuration in a "reporting" tag (not reportSets). In the "build" tag, I just put the plugin information and the dependencies. The configuration used the default values for the output xml and output folder. I also added file which was filtering out some of the bugs:

<build>
        <plugins>
            <plugin>
                <groupId>com.github.spotbugs</groupId>
                <artifactId>spotbugs-maven-plugin</artifactId>
                <version>3.1.10</version>
                <dependencies>
                    <dependency>
                        <groupId>com.github.spotbugs</groupId>
                        <artifactId>spotbugs</artifactId>
                        <version>3.1.11</version>
                    </dependency>
                </dependencies>
            </plugin>
        </plugins>
    </build>
    <reporting>
        <plugins>
            <plugin>
                <groupId>com.github.spotbugs</groupId>
                <artifactId>spotbugs-maven-plugin</artifactId>
                <version>3.1.10</version>
                <configuration>
                    <excludeFilterFile>spotbugs_filter.xml</excludeFilterFile>
                </configuration>
            </plugin>
        </plugins>
    </reporting>

然后我做了一个

mvn clean install site spotbugs:check

这给了我:

  • build_directory 中的一个 spotbugsXml.xml 文件,其中包含发现的所有错误(未应用过滤器).
  • 在目标/站点中生成了一份报告 spotbugs.html,其中包含过滤后的错误列表.

因此,要将其与您的问题联系起来,我想使用这些步骤"您可以得到两份报告,一份有阈值,另一份没有.

So, to link this with your issue, I guess that using these "steps" you can have two reports, one with the threshold and another one without.

这有意义吗?