RuF
RuF

Reputation: 558

How to know which PMD rule fails?

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.

Upvotes: 4

Views: 5031

Answers (2)

adangel
adangel

Reputation: 1910

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.

Upvotes: 2

Jiri Tousek
Jiri Tousek

Reputation: 12450

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

Upvotes: 2

Related Questions