Skip to content

Enforce and report code quality with JUnit, JaCoCo, Hamcrest, FindBugs, PMD, CodeNarc, Checkstyle (Google), Enforcer, Duplicate-Finder, JDepend, and more with this Maven POM.

License

Notifications You must be signed in to change notification settings

gregswindle/maven-code-quality-pom

Repository files navigation

maven-code-quality-pom

Enforce and report code quality with JUnit, JaCoCo, Hamcrest, FindBugs, PMD, CodeNarc, Checkstyle (Google), Enforcer, Duplicate-Finder, JDepend, and more with this Maven POM.

License Third-party licenses Synk Vulnerabilities Build Status Coveralls Status
Dependency Status Dependency Status DevDependency Status Greenkeeper badge

Table of contents

1. Overview

Enforce and report code quality with:

  1. Checkstyle with Google Java coding standards (maven-checkstyle-plugin)
  2. CodeNarc (codenarc-maven-plugin)
  3. Duplicate-Finder (duplicate-finder-maven-plugin)
  4. Enforcer (maven-enforcer-plugin)
  5. FindBugs (findbugs-maven-plugin)
  6. fmt-maven-plugin formats your code using google-java-format, which follows Google's code styleguide (fmt-maven-plugin)
  7. JDepend (jdepend-maven-plugin)
  8. JUnit (junit5 with junit4 backwards compatibility)
  9. JaCoCo (jacoco-maven-plugin)
  10. PMD (maven-pmd-plugin)
  11. Report site generation (maven-site-plugin)

and more with this Maven POM.


The purpose of the project is to use the Maven Site Plugin to:

  1. Use the Maven Site Plugin to generate meaningful test and quality reporting artifacts
  2. Enforce test coverage thresholds and code standards
  3. Prevent source code that does not conform to standards from being merged into master.

2. Prerequisite software

[Java logo]]java-jdk-dl-url Maven logo Node.js logo      npm logo

maven-code-quality-pom is written in Java, which must be installed prior to use. maven-code-quality-pom manages Java dependencies with Maven and NPM for JavaScript dependencies.

  1. Java™️ EE 8 SDK: Either

  2. Maven

  3. Node.js, which includes the node package manager (npm).

3. Installation

💡 If you're working on macOS, we recommend installing or updating software with Homebrew.

  1. Fork or clone this repository.
$ git clone https://github.com/gregswindle/maven-code-quality-pom.git
$ cd maven-code-quality-pom
  1. Install with Maven:
$ mvn clean install -DskipTests=true -Dmaven.javadocs.skip=true -B -V
  1. Install Node.js dependencies:
$ npm install

4. Usage

4.1. Run unit tests, evaluate complexity, and check coverage

$ mvn test verify

4.2. Generate site files

To build the Maven reports site, open a Terminal and run:

$ mvn site

Then open maven-code-quality-pom/target/site/index.html in a Web browser.

4.3. Run quality checks

  • 4.3.1. mvn fmt:check

    Formats all src/ and test/ Java code according to the Google Java style guide.

    ℹ️ mvn fmt:format runs with every build.

  • 4.3.2. mvn enforcer:display-info

    Executes the defined enforcer-rules once per module and displays the current platform information

  • 4.3.3. mvn site

    Generates the site for a single project.

  • 4.3.4. mvn checkstyle:check

    Performs Checkstyle analysis and outputs violations or a count of violations to the console, potentially failing the build.

  • 4.3.5. mvn duplicate-finder:check

    Finds duplicate classes/resources on the classpath.

  • 4.3.6. mvn findbugs:check

    Identify defect (bug) patterns in your Java source code.

  • 4.3.7. mvn pmd:check

    Fail the build if there were any PMD violations in the source code.

  • 4.3.8. mvn pmd:cpd-check

    Fail the build if there were any CPD violations in the source code.

4.3. Export reports to SonarCloud.io

SonarCloud logo

Before you connect to SonarCloud, you need:

See "Using SonarCloud with Travis CI" for details.

Open a Terminal and run:

$ mvn clean org.jacoco:jacoco-maven-plugin:prepare-agent install sonar:sonar

View reports on SonarCloud.

5. Semantic version and CHANGELOG

The latest version of maven-code-quality-pom is 0.0.1-SNAPSHOT. View the CHANGELOG for details.

6. Contributing to maven-code-quality-pom

Learn how to make a Pull Request with free training

We welcome contributors with Pull Requests!

🍀 Read Contributing to maven-code-quality-pom to get started. 🍀

Contributions in the form of GitHub pull requests are welcome. Before embarking on a significant change, please adhere to the following guidelines:

  1. Read the Code of Conduct.
  2. Create an issue to discuss the proposed change and ensure that it is likely to be merged:
  3. Follow Contributing to maven-code-quality-pom's coding conventions and Git workflow if you're willing and able to program (or want to learn how).

7. License

MIT © Greg Swindle.

FOSSA Status

About

Enforce and report code quality with JUnit, JaCoCo, Hamcrest, FindBugs, PMD, CodeNarc, Checkstyle (Google), Enforcer, Duplicate-Finder, JDepend, and more with this Maven POM.

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published