46 lines
2.2 KiB
Markdown
Executable file
46 lines
2.2 KiB
Markdown
Executable file
# [bld](https://rife2.com/bld) Extension to Perform Static Code Analysis with [PMD](https://pmd.github.io/)
|
|
|
|
|
|
[](https://opensource.org/licenses/Apache-2.0)
|
|
[](https://www.oracle.com/java/technologies/javase/jdk17-archive-downloads.html)
|
|
[](https://rife2.com/bld)
|
|
[](https://repo.rife2.com/#/releases/com/uwyn/rife2/bld-pmd)
|
|
[](https://repo.rife2.com/#/snapshots/com/uwyn/rife2/bld-pmd)
|
|
[](https://github.com/rife2/bld-pmd/actions/workflows/bld.yml)
|
|
|
|
To install, please refer to the [extensions documentation](https://github.com/rife2/bld/wiki/Extensions).
|
|
|
|
To check all source code using the [Java Quickstart](https://pmd.github.io/pmd/pmd_rules_java.html) configuration, add the following to your build file:
|
|
|
|
```java
|
|
@BuildCommand(summary = "Checks source code with PMD")
|
|
public void pmd() throws Exception {
|
|
new PmdOperation()
|
|
.fromProject(this)
|
|
.execute();
|
|
}
|
|
```
|
|
|
|
```console
|
|
./bld pmd test
|
|
```
|
|
|
|
To check the main source directory using a custom ruleset, [Java Error Prone](https://pmd.github.io/pmd/pmd_rules_java.html#error-prone) configuration, and failing on any violation.
|
|
|
|
```java
|
|
@BuildCommand(value = "pmd-main", summary = "Checks main source code with PMD")
|
|
public void pmdMain() throws Exception {
|
|
new PmdOperation()
|
|
.fromProject(this)
|
|
.failOnViolation(true)
|
|
.inputPaths(this.srcMainDirectory().toPath())
|
|
.ruleSets("config/pmd.xml", "category/java/errorprone.xml")
|
|
.execute();
|
|
}
|
|
```
|
|
|
|
```console
|
|
./bld compile pmd-main
|
|
```
|
|
|
|
Please check the [PmdOperation documentation](https://rife2.github.io/bld-pmd/rife/bld/extension/PmdOperation.html#method-summary) for all available configuration options.
|