a FindBugs/SpotBugs plugin for doing static code analysis for java code bases
a FindBugs and SpotBugs plugin for doing static code analysis on java byte code.
For information see http://fb-contrib.sf.net
Available on maven.org
for FindBugs:
GroupId: com.mebigfatguy.fb-contrib
ArtifactId: fb-contrib
Version: 7.6.8
For SpotBugs
GroupId: com.mebigfatguy.sb-contrib
ArtifactId: sb-contrib
Version: 7.6.8
Developer
Contributors
fb-contrib has two main branches, ‘findbugs’ and ‘spotbugs’. Code is committed to spotbugs, and then merged back to findbugs.
It is preferable therefore to create merge requests against the spotbugs branch. Thanks!
git clone https://code.google.com/p/findbugs/
You will only need the findbugs subfolder (the one that has README.txt in it). You can delete the rest, if you wish.user.properties.example
file. Make a copy of it named user.properties (this will not be tracked by version control). Modify the findbugs.dir property to where ever you have the FindBugs distribution installed. This is the executable FindBugs folder, not the source folder. The jar will be “installed” to (findbugs.dir)\plugin.findbugs.dir=/eclipse/plugins/edu.umd.cs.findbugs.plugin.eclipse_3.0.0.20140706-2cfb468
mvn clean install
in the fb-contrib directory.To include the fb-contrib detectors when checking your project with FindBugs, you can use the FindBugs Maven plugin.
The group ID for fb-contrib is com.mebigfatguy.fb-contrib, and the artifact ID is fb-contrib. Eg:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
<version>3.0.4</version>
<configuration>
<plugins>
<plugin>
<groupId>com.mebigfatguy.fb-contrib</groupId>
<artifactId>fb-contrib</artifactId>
<version>7.6.8</version>
</plugin>
</plugins>
</configuration>
<executions>
<execution>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
Or to include the fb-contrib detectors when checking your project with Spotbugs, you can use the SpotBugs Maven plugin which is a fork of findbugs maven plugin to provide spotbugs integration.
The group ID for sb-contrib is com.mebigfatguy.sb-contrib, and the artifact ID is sb-contrib. Eg:
<plugin>
<groupId>com.github.spotbugs</groupId>
<artifactId>spotbugs-maven-plugin</artifactId>
<version>3.1.12</version>
<configuration>
<plugins>
<plugin>
<groupId>com.mebigfatguy.sb-contrib</groupId>
<artifactId>sb-contrib</artifactId>
<version>7.6.8</version>
</plugin>
</plugins>
</configuration>
<executions>
<execution>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
apply plugin: 'findbugs'
dependencies {
// We need to manually set this first, or the plugin is not loaded
findbugs 'com.google.code.findbugs:findbugs:3.0.0'
findbugs configurations.findbugsPlugins.dependencies
// To keep everything tidy, we set these apart
findbugsPlugins 'com.mebigfatguy.fb-contrib:fb-contrib:7.6.8'
}
task findbugs(type: FindBugs) {
// Add all your config here ...
pluginClasspath = project.configurations.findbugsPlugins
}
Once you have the dev environment set up, feel free to make changes and pull requests.
Any edits are much appreciated, from finding typos, to adding examples in the messages, to creating new detectors, all help is welcome.
External guides for making detectors:
Misc references about bytecode:
For making detectors, it best to make several test cases, like those in the sample directory. Even better is if you can comment where you expect bug markers to appear and why, like this.
In your pull request, give an overview of your changes along with the related commits.
If you are not up for contributing code but notice a common problem with some third party library, or general purpose pattern, please add an issue too. We always like new ideas.
Often available on #fb-contrib on freenode.net for conversation.