Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to know which PMD rule fails?

Tags:

java

maven

pmd

Maven-pmd-plugin used in the project. When I try to deploy the project, it fails with the following error:

Caused by: org.apache.maven.plugin.MojoFailureException: PMD check threshold has been set to severity level 'error' - detected 1 violation(s) at that (or greater than that) level and 'failOnViolation' is true - failing the build

How can I know which rule is fail? What violation is found?

Executing Maven with -e or -X does not help.

like image 874
RuF Avatar asked Sep 02 '25 10:09

RuF


2 Answers

There should be a HTML report generated in target/site/pmd.html that lists detected issues (issue description and line).

like image 170
Jiri Tousek Avatar answered Sep 05 '25 00:09

Jiri Tousek


You can also build your project with the option -Dpmd.printFailingErrors=true or configure the maven plugin in the pom.xml file:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-pmd-plugin</artifactId>
    <version>3.8</version>
    <configuration>
        <printFailingErrors>true</printFailingErrors>
    </configuration>
    ....
</plugin>

See https://maven.apache.org/plugins/maven-pmd-plugin/check-mojo.html#printFailingErrors

This will print out the rule violations directly in the console.

like image 34
adangel Avatar answered Sep 04 '25 23:09

adangel