Checkstats Maven Plugin

Keep your Jacoco, Findbugs, Pmd, or Cpd error statistics decreasing as code is added.

License

License

Categories

Categories

Maven Build Tools
GroupId

GroupId

org.honton.chas
ArtifactId

ArtifactId

checkstats-maven-plugin
Last Version

Last Version

0.0.1
Release Date

Release Date

Type

Type

maven-plugin
Description

Description

Checkstats Maven Plugin
Keep your Jacoco, Findbugs, Pmd, or Cpd error statistics decreasing as code is added.
Project URL

Project URL

https://github.com/chonton/checkstats-maven-plugin
Source Code Management

Source Code Management

https://github.com/chonton/checkstats-maven-plugin

Download checkstats-maven-plugin

How to add to project

<plugin>
    <groupId>org.honton.chas</groupId>
    <artifactId>checkstats-maven-plugin</artifactId>
    <version>0.0.1</version>
</plugin>

Dependencies

compile (6)

Group / Artifact Type Version
com.google.code.findbugs : annotations jar 3.0.1
com.google.code.gson : gson jar 2.4
org.apache.maven : maven-model jar 2.2.1
org.apache.maven : maven-plugin-api jar 3.0
org.apache.maven : maven-project jar 2.2.1
org.eclipse.aether : aether-api jar 1.0.2.v20150114

provided (2)

Group / Artifact Type Version
org.apache.maven.plugin-tools : maven-plugin-annotations jar 3.2
org.projectlombok : lombok jar 1.16.6

test (1)

Group / Artifact Type Version
junit : junit jar 4.8.2

Project Modules

There are no modules declared in this project.

checkstats-maven-plugin

Keep your Jacoco, Findbugs, Pmd, or Cpd error statistics decreasing as code is added.

When starting a new maven project, it's relatively straight-forward to enforce code hygiene. You add unit and integration tests to verify code functionality; add checkstyle, findbugs, cpd, and pmd to guard code quality, and add jacoco to validate code coverage. Finally, you add rules for each plugin to enforce minimum standards.

When you inherit a project that doesn't have these basics, it's difficult to start enforcing minimum standards. Anyone on the project can add new code without new unit tests. It's tough to determine what's legacy code which gets a free pass and what's new code which must adhere to the new standards. Typically, we give up in despair and the code continues in it's sorry state.

Checkstats helps you climb out of this state by failing any build which does not keep or decrease the prior build's quality statistics. The supported statistics are checkstyle's error count, cpd's duplicate count, pmd's violations, findbug's bugCount, and jacoco's missed coverage percentage.

Checkstats provides a single goal, "check". This goal parses the xml output reports of checkstyle, cpd, pmd, findbugs, and jacoco. To ensure these reports are available, the "check" goal is attached by default to the "verify" phase. The supported reports should be attached to earlier phases, usually "validate", or "prepare-package"/"post-integration-test" for jacoco.

If a report exists, checkstats compares the code quality statistic with the statistic from the prior successful build. Once all quality statistics are successfully verified, they are saved as an attached maven artifact with classifier "stats". This attached artifact will be saved as part of the deploy phase. All of a development team and automation will share the code quality statistics. Because it is an attached artifact, the quality metric baseline is reset with each project version change.

Following is a typical use of checkstats:

  <build>
    <plugins>

      <plugin>
        <groupId>org.honton.chas</groupId>
        <artifactId>checkstats-maven-plugin</artifactId>
        <version>0.0.1</version>
        <executions>
          <execution>
            <goals>
              <goal>check</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-checkstyle-plugin</artifactId>
        <version>2.17</version>
        <executions>
          <execution>
            <goals>
              <goal>check</goal>
            </goals>
            <phase>validate</phase>
            <configuration>
              <configLocation>google_checks.xml</configLocation>
            </configuration>
          </execution>
        </executions>
      </plugin>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-pmd-plugin</artifactId>
        <version>3.5</version>
        <configuration>
          <skipEmptyReport>false</skipEmptyReport>
        </configuration>
        <executions>
          <execution>
            <id>cpd</id>
            <goals>
              <goal>cpd</goal>
            </goals>
            <phase>validate</phase>
          </execution>
          <execution>
            <id>pmd</id>
            <goals>
              <goal>pmd</goal>
            </goals>
            <phase>validate</phase>
          </execution>
        </executions>
      </plugin>

      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>findbugs-maven-plugin</artifactId>
        <version>3.0.2</version>
        <configuration>
          <effort>Max</effort>
          <threshold>Low</threshold>
        </configuration>
        <executions>
          <execution>
            <id>analyze-compile</id>
            <goals>
              <goal>findbugs</goal>
            </goals>
            <phase>process-classes</phase>
          </execution>
        </executions>
      </plugin>

      <plugin>
        <groupId>org.jacoco</groupId>
        <artifactId>jacoco-maven-plugin</artifactId>
        <version>0.7.5.201505241946</version>
        <executions>
          <execution>
            <id>default-prepare-agent</id>
            <goals>
              <goal>prepare-agent</goal>
            </goals>
          </execution>
          <execution>
            <id>default-report</id>
            <goals>
              <goal>report</goal>
            </goals>
            <phase>prepare-package</phase>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>

Versions

Version
0.0.1