bld-pmd/README.md

2.4 KiB
Executable file

bld Extension to Perform Static Code Analysis with PMD

License Java bld Release Snapshot GitHub CI

To install the latest version, add the following to the lib/bld/bld-wrapper.properties file:

bld.extension-pmd=com.uwyn.rife2:bld-pmd

For more information, please refer to the extensions documentation.

Check Source with PMD

To check all source Codecode using the Java Quickstart configuration, add the following to your build file:

@BuildCommand(summary = "Checks source code with PMD")
public void pmd() throws Exception {
    new PmdOperation()
        .fromProject(this)
        .execute();
}
./bld pmd test

To check the main source directory using a custom ruleset, Java Error Prone configuration, and failing on any violation.

@BuildCommand(value = "pmd-main", summary = "Checks main source code with PMD")
public void pmdMain() throws Exception {
    new PmdOperation()
            .fromProject(this)
            .failOnViolation(true)
            .inputPaths(srcMainDirectory())
            .ruleSets("config/pmd.xml", "category/java/errorprone.xml")
            .execute();
}
./bld compile pmd-main

Please check the PmdOperation documentation for all available configuration options.