43 lines
1.8 KiB
Markdown
Executable file
43 lines
1.8 KiB
Markdown
Executable file
# [Bld](https://rife2.com/bld) Extension to Perform Static Code Analysis with [PMD](https://pmd.github.io/)
|
|
|
|
|
|
[](http://opensource.org/licenses/BSD-3-Clause)
|
|
[](https://www.oracle.com/java/technologies/javase/jdk17-archive-downloads.html)
|
|
[](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 check all source code using the [java quickstart rule](https://pmd.github.io/pmd/pmd_rules_java.html).
|
|
|
|
```java
|
|
@BuildCommand
|
|
public void pmd() throws Exception {
|
|
new PmdOperation()
|
|
.fromProject(this)
|
|
.execute();
|
|
}
|
|
```
|
|
|
|
```text
|
|
./bld pmd test
|
|
```
|
|
|
|
To check the main source directory using a custom rule, [java error prone rule](https://pmd.github.io/pmd/pmd_rules_java.html) and failing on any violation.
|
|
|
|
```java
|
|
@BuildCommand
|
|
public void pmdMain() throws Exception {
|
|
new PmdOperation()
|
|
.fromProject(this)
|
|
.failOnViolation(true)
|
|
.inputPaths(this.srcMainDirectory().toPath())
|
|
.ruleSets("config/pmd.xml", "category/java/errorprone.xml")
|
|
.execute();
|
|
}
|
|
```
|
|
|
|
```text
|
|
./bld compile pmdMain
|
|
```
|
|
|
|
Please check the [PmdOperation documentation](https://rife2.github.io/bld-pmd/rife/bld/extension/PmdOperation.html#method-summary) for all available configuration options.
|