[ 
https://issues.apache.org/jira/browse/MPMD-383?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17906401#comment-17906401
 ] 

Andreas Dangel commented on MPMD-383:
-------------------------------------

I think, in depends on _how_ maven-pmd-plugin is used in the project (and 
that's a project decision and can vary between projects of course):
If m-pmd-p is used as a reporting plugin for the project site, then yes, this 
is only advisory.
On the other hand, if m-pmd-p is used as a check goal, then the intention of 
the project is, that the project should fail whenever PMD finds a problem 
(whether PMD is correct or not is another topic). This means, the project 
relies on PMD executing successfully. If a processing error occurs, this means, 
that PMD potentially didn't analyze a file or didn't execute a rule (again, why 
this is the case is another topic and means usually a bug in PMD). This in turn 
means, that PMD potentially could miss problems, that otherwise would have 
failed the build and prevented the project from continuing in the process of 
publishing their software (as the build would have failed, if there would have 
no processing errors and there would have been violations in the skipped files).

In other words: if the check goal of m-pmd-p is used, then the expectation with 
the least surprising behavior (IMHO) is, that if m-pmd-p detects, that it 
couldn't check what it is supposed to check (because of a processing errors), 
it should fail and not pretend "there are no errrors, everything is good". 
Which gives a false sense of security.

I suspect, the underlying issue is that "pmd:pmd" is used for two use cases 
with different requirements:
a) create a report - here we want to report as much as possible, not failing 
even in the face of processing errors, so that we can nicely report even the 
processing errors, with a big warning: "due to processing errors, the report 
might be incomplete". Here we want {{{}skipPmdError=true{}}}.
b) fail the build if the quality goals for the project are not met or if the 
quality goals can't be checked - this is implemented via the pmd:check goal, 
which _reuses_ pmd:pmd to determine the violations. Here we want 
{{{}skipPmdError=false{}}}.

Btw - whether PMD is or is not just a primarily advisory is a project decision, 
not a tool decision. The question is how the tool is used. Unit tests also 
don't contribute to the output byte code of the artifacts, but usually you want 
to fail the build, if the unit tests fail or can't be executed at all, as you 
don't want to miss the fact, that unit tests are failing (which might indicate 
the product doesn't work as expected).

Btw2: Since the processing errors are issued as warnings by default, this can 
be used by CI tools. Some projects run the policy "no warnings during build" 
and actively search for any warning messages and fail the build in such cases, 
to prevent that no one notices that something is odd.

> PMD should fail when there is a processing error
> ------------------------------------------------
>
>                 Key: MPMD-383
>                 URL: https://issues.apache.org/jira/browse/MPMD-383
>             Project: Maven PMD Plugin
>          Issue Type: Wish
>          Components: PMD
>    Affects Versions: 3.21.0
>            Reporter: Thomas Nikolay
>            Priority: Major
>         Attachments: image-2023-07-28-13-34-28-717.png
>
>
> We had the case that PMD can't process some processing error but the build 
> does not fail.
>  
> {noformat}
> [2023-07-28T10:59:44.102Z] [INFO] --- maven-pmd-plugin:3.20.0:pmd (pmd) @ 
> mod-config-client-cst ---
> [2023-07-28T10:59:44.692Z] [INFO] PMD version: 6.53.0
> [2023-07-28T10:59:45.672Z] [WARNING] Removed misconfigured rule: 
> GK-SAP-ApacheLoggerDeniedRule  cause: missing value
> [2023-07-28T10:59:45.672Z] [WARNING] There are 3 PMD processing errors:
> [2023-07-28T10:59:45.672Z] [WARNING] 
> /var/lib/hudson-slave/workspace/hmr.MAIN.00-FEATURE-BRANCHES/pos/config/mod-config-client-cst/src/test/java/com/gk_software/cst/client/AppInfoProviderImpl_CST_Test.java:
>  PMDException: Error while processing 
> /var/lib/hudson-slave/workspace/hmr.MAIN.00-FEATURE-BRANCHES/pos/config/mod-config-client-cst/src/test/java/com/gk_software/cst/client/AppInfoProviderImpl_CST_Test.java
> [2023-07-28T10:59:45.948Z] 
> /var/lib/hudson-slave/workspace/hmr.MAIN.00-FEATURE-BRANCHES/pos/config/mod-config-client-cst/src/test/java/com/gk_software/pos/api/model/config/component/client/print/additional_printout/Trigger_CFH_CST_Test.java:
>  PMDException: Error while processing 
> /var/lib/hudson-slave/workspace/hmr.MAIN.00-FEATURE-BRANCHES/pos/config/mod-config-client-cst/src/test/java/com/gk_software/pos/api/model/config/component/client/print/additional_printout/Trigger_CFH_CST_Test.java
> [2023-07-28T10:59:45.948Z] 
> /var/lib/hudson-slave/workspace/hmr.MAIN.00-FEATURE-BRANCHES/pos/config/mod-config-client-cst/src/main/java/com/gk_software/pos/api/model/config/component/client/print/additional_printout/Trigger_CFH_CST.java:
>  PMDException: Error while processing 
> /var/lib/hudson-slave/workspace/hmr.MAIN.00-FEATURE-BRANCHES/pos/config/mod-config-client-cst/src/main/java/com/gk_software/pos/api/model/config/component/client/print/additional_printout/Trigger_CFH_CST.java
> [2023-07-28T10:59:45.948Z] [INFO] Rendering content with 
> org.apache.maven.skins:maven-default-skin:jar:1.3 skin.
> [2023-07-28T10:59:46.210Z] [INFO] 
> [2023-07-28T10:59:46.210Z] [INFO] <<< maven-pmd-plugin:3.20.0:check 
> (pmd-check) < :pmd @ mod-config-client-cst <<<
>  {noformat}
>  
> My expectation would be that the build failed when there a processing errors. 
>  



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to