如何配置 SpotBugs maven 插件以创建完整报告但仅检查高阈值? [英] How to configure SpotBugs maven plugin to create a full report but check for high threshold only?

查看:173
本文介绍了如何配置 SpotBugs maven 插件以创建完整报告但仅检查高阈值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个遗留的 Maven 项目,并且想要集成 FindBugs 后继 SpotBugs 以创建所有问题的报告,但如果出现 仅限优先事项(目前).

I have a legacy maven project and want to integrate the FindBugs successor SpotBugs to create a report of all issues but fail if there a High priority issues only (for now).

很容易创建报告而不会失败在特定阈值上失败.但是,当指定阈值时,所有低于该阈值的问题也会从报告中删除.

It is easy to create the report only without fail ing or to fail on a specific threshold. But when specifying a threshold all issues below that one are also removed from the report.

我尝试根据文档 但没有成功:

I have tried to configure the plugin according to to documentation but without success:

<plugin>
  <groupId>com.github.spotbugs</groupId>
  <artifactId>spotbugs-maven-plugin</artifactId>
  <version>3.1.3</version>
  <configuration>
    <effort>Max</effort>
    <threshold>High</threshold>
    <xmlOutput>true</xmlOutput>
    <spotbugsXmlOutputDirectory>${project.build.directory}/spotbugs-reports</spotbugsXmlOutputDirectory>
    <xmlOutputDirectory>${project.build.directory}/spotbugs-reports</xmlOutputDirectory>
    </configuration>
    <executions>
      <execution>
        <goals>
          <goal>check</goal>
        </goals>
      </execution>
    </executions>
  </plugin>

我使用的是 Maven 3 和 SpotBugs 3.1.3.

I am using Maven 3 and SpotBugs 3.1.3.

推荐答案

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

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.

这有意义吗?

这篇关于如何配置 SpotBugs maven 插件以创建完整报告但仅检查高阈值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆