Generate a Bug Report Maven FindBugs Plugin

When we don’t want to run static code analysis every time our project is compiled, we can generate a bug report during the site phase of the project. This way we can manually generate a bug report for our project. Or create a periodical report using a CI tool.

We are using the following class to demonstrate a simple use case how maven findbugs plugin generates a bug report. Can you spot the bugs in the following code?

package com.memorynotfound;

public class ClassWithBug {

    public String execute() {
        String str = null;
        return str.toUpperCase();


We can generate a bug report using the maven findbugs plugin by following these steps:

  1. Add the findbugs-maven-plugin to the reporting section of the pom.xml file.
  2. Make sure that most accurate analysis is performed by setting the efford element to Max.
  3. Make sure that all bugs are reported by setting the efford element to low.
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns=""

    <name>MAVEN FINDBUGS - ${project.artifactId}</name>




We can generate the bug report using the following maven command:

mvn compile site

When the maven command is executed it generates the following output.

[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building MAVEN FINDBUGS - create-report-part-of-project-reports 1.0.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] --- maven-site-plugin:3.3:site (default-site) @ create-report-part-of-project-reports ---
[INFO] configuring report plugin org.codehaus.mojo:findbugs-maven-plugin:3.0.3
[INFO] Fork Value is true
     [java] Warnings generated: 3
[INFO] Done FindBugs Analysis....
[INFO] Generating "FindBugs" report    --- findbugs-maven-plugin:3.0.3
[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------

Demo Bug Report

When the build is successful, maven has generated a bug report in the target/site folder. The following screenshot is a result of the generated bug report of the findbugs-maven-plugin.

generate bug report maven findbugs plugin

You may also like...