Skip to content

Instantly share code, notes, and snippets.

@gmanfunky
Created August 26, 2015 20:43
Show Gist options
  • Save gmanfunky/b6d667980858f3918353 to your computer and use it in GitHub Desktop.
Save gmanfunky/b6d667980858f3918353 to your computer and use it in GitHub Desktop.
A maven profile section to run findbugs on all maven sub-modules using an exclude filter. Able to toggle on build failure with mvn verify -Pfindbugs -Dfindbugs.failOnError=true
<?xml version="1.0"?>
<!--
This file contains some false positive bugs detected by Findbugs. Their
false positive nature has been analyzed individually and they have been
put here to instruct Findbugs it must ignore them.
Reference:
This file format: http://findbugs.sourceforge.net/manual/filter.html
Bug pattern names and codes: http://findbugs.sourceforge.net/bugDescriptions.html
Bug categories: https://code.google.com/p/findbugs/source/browse/findbugs/etc/findbugs.xml
-->
<FindBugsFilter>
<!-- Examples of how to make a bug matching filter -->
<!--
<Match>
<Class name="~.*\.Messages" />
<Or>
<Bug code="UUF" />
<Bug pattern="RV_ABSOLUTE_VALUE_OF_RANDOM_INT" />
<Bug category="PERFORMANCE,MALICIOUS_CODE" />
</Or>
</Match>
-->
<!-- Don't bother with Performance category.
Don't bother with exposing internals to other classes ("malicious" code)-->
<Match>
<Bug category="PERFORMANCE,MALICIOUS_CODE" />
</Match>
<!-- Ignore test stuff unless security or Junit specific rule -->
<Match>
<Or>
<!--<Class name="~.*\.*Test" /> -->
<Class name="~.*Test" />
<Package name="~.*Test\.?.*" />
</Or>
<Not>
<Or>
<Bug category="SECURITY" />
<Bug code="IJU" />
</Or>
</Not>
</Match>
<!-- at 100 invocations per second, it would take on average 200 days to hit this incorrect case. -->
<Match>
<Bug pattern="RV_ABSOLUTE_VALUE_OF_RANDOM_INT" />
</Match>
</FindBugsFilter>
<profiles>
<profile>
<id>findbugs</id>
<activation>
<activeByDefault>false</activeByDefault>
</activation>
<properties>
<findbugs.maven.version>3.0.2</findbugs.maven.version>
<findbugs.failOnError>false</findbugs.failOnError>
</properties>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
<version>${findbugs.maven.version}</version>
<executions>
<execution>
<id>findbugs</id>
<phase>verify</phase>
<configuration>
<failOnError>${findbugs.failOnError}</failOnError>
<effort>Max</effort>
<threshold>Default</threshold>
<xmlOutput>true</xmlOutput>
<excludeFilterFile>${basedir}/../findbugs-exclude-filter.xml</excludeFilterFile>
</configuration>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
<version>${findbugs.maven.version}</version>
<executions>
<execution>
<id>findbugs</id>
<phase>test</phase>
<configuration>
</configuration>
<goals>
<goal>findbugs</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment