【问题标题】:Set custom findBugs rules, disable failsOnViolation using qulice-maven-plugin设置自定义 findBugs 规则,使用 qulice-maven-plugin 禁用 failedOnViolation
【发布时间】:2016-05-25 12:02:29
【问题描述】:

我想使用qulice-maven-plugin,我不想使用默认的findBugs 规则,而是设置我的自定义一次。那可能吗? - 另外,我不希望 qulice-maven-plugin 在违反 checkstyle 时失败,但我不想禁用该插件。如何更改默认的qulice-maven-plugin、checkstyle配置?

<build>
  <plugins>
    <plugin>
      <groupId>com.qulice</groupId>
      <artifactId>qulice-maven-plugin</artifactId>
      <version>0.16.4</version>
      <configuration>
        <license>file:${basedir}/LICENSE.txt</license>
      </configuration>
      <executions>
        <execution>
          <goals>
            <goal>check</goal>
          </goals>
        </execution>
      </executions>
    </plugin>
  </plugins>
</build>

【问题讨论】:

  • 首先我会根据文档删除许可证配置,这是默认设置。此外,我会问 qulice-maven-plugin 的创建者 ...

标签: java maven findbugs qulice


【解决方案1】:

无法覆盖 qulice 中的规则。它背后的基本思想是它有一套不可更改的规则。所以每个使用 qulice 的项目看起来都差不多。

您只能使用 regexp (checkstyle:.*) 禁用 qulice,如下所示:

<plugin>
    <groupId>com.qulice</groupId>
    <artifactId>qulice-maven-plugin</artifactId>
    <version>0.16.5</version>
    <configuration>
        <license>file:./LICENSE.txt</license>
        <excludes>
            <exclude>findbugs:~com.qulice.foo.M.*</exclude>
            <exclude>findbugs:com.qulice.foo.Bar</exclude>
            <exclude>findbugs:.*</exclude>
            <exclude>checkstyle:.*</exclude>
        </excludes>
    </configuration>
    <executions>
        <execution>
            <goals>
                <goal>check</goal>
            </goals>
        </execution>
    </executions>
</plugin>

因此您只能实现第二个要求 - 如果 checkstyle 失败,构建不会失败。 对于 findbugs,您需要像这样使用 SuppressFBWarnings(来自 edu.umd.cs.findbugs.annotations):@SuppressFBWarnings("JLM_JSR166_UTILCONCURRENT_MONITORENTER")

【讨论】:

  • 谢谢。但是我有一些不必要的规则,它们会在报告中引起很多噪音。我需要更大的配置能力。目前我认为 qulice 并不能满足我项目的要求,它不会降低我的 maven 脚本的复杂性,甚至会使其变得更复杂,会造成更多的麻烦。
  • @Xelian 直接使用 Checkstyle 和 PMD 并按照您需要的方式配置它们
猜你喜欢
  • 2013-02-14
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-02-22
  • 1970-01-01
  • 2021-02-13
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多