简体   繁体   English

设置Maven Findbugs的基准

[英]Setup baseline for Maven Findbugs

I have this issue that I have been trying to solve for the better part of a day, but can't really seem to do. 我一直试图解决这一问题,但实际上似乎并不能解决。

I have set up my maven so that it fails if findbugs finds any bugs. 我已经设置了我的Maven,以便在findbugs发现任何bug时它都会失败。 However, because of reasons, I would like to ignore all the bugs that currently exist in the project, and only fail if new bugs are found. 但是,由于种种原因,我想忽略项目中当前存在的所有错误,并且仅在发现新错误时才会失败。 A baseline. 基线。

I am able to generate an XML file containing a <BugCollection> with all my current bugs, using FindBugs plugin for IntelliJ. 我可以使用IntelliJ的FindBugs插件生成包含<BugCollection>以及所有当前错误的XML文件。 However, supplying this to the maven plugin does nothing. 但是,将此内容提供给Maven插件没有任何作用。

It seems the maven plugin requires a filter file in this format: 看来Maven插件需要以下格式的过滤器文件:

 <Match>
   <Class name="com.foobar.MyClass" />
 </Match>

My question is then: How do I generate this filter file? 我的问题是:如何生成此过滤器文件?

It seems that the findbugs:gui is not a great option, as it only allows me to filter on bug type and class. 似乎findbugs:gui不是一个好选择,因为它只允许我过滤错误类型和类。 Meaning new bugs of the same type in the same class but a different method would be ignored. 意味着在同一个类中具有相同类型但有不同方法的新错误将被忽略。

Alternatively: How do I make findbugs for maven ignore existing bugs and only fail on new ones? 或者:如何使Maven的findbug忽略现有的bug,而仅在新的bug上失败?

Thank you :) 谢谢 :)

You should use the excludeBugsFile configuration, something like below. 您应该使用excludeBugsFile配置,如下所示。 The findbugs-baseline.xml is the file exported with the FindBugs-IDEA plugin in Intellij findbugs-baseline.xml是随Intellij中的FindBugs-IDEA插件一起导出的文件

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>findbugs-maven-plugin</artifactId>
    <configuration>
      <excludeBugsFile>${project.basedir}/findbugs-baseline.xml</excludeBugsFile>
    </configuration>
    <executions>
      <execution>
        <goals>
          <goal>check</goal>
        </goals>
      </execution>
    </executions>
  </plugin>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM