Skip to content

Pull #18529: Fix wrong test scope for PMD#18529

Merged
romani merged 1 commit into
checkstyle:masterfrom
Pankraz76:fix-pmd
Jan 20, 2026
Merged

Pull #18529: Fix wrong test scope for PMD#18529
romani merged 1 commit into
checkstyle:masterfrom
Pankraz76:fix-pmd

Conversation

@Pankraz76

@Pankraz76 Pankraz76 commented Jan 6, 2026

Copy link
Copy Markdown

Pull #18529: Fix wrong test scope for PMD #18470

Comment thread .circleci/config.yml Outdated
Comment thread .ci/validation.sh
Comment thread .ci/validation.sh
@Pankraz76

Copy link
Copy Markdown
Author

reopen after enabler:

@Pankraz76 Pankraz76 closed this Jan 9, 2026
@Pankraz76 Pankraz76 reopened this Jan 11, 2026
@Pankraz76 Pankraz76 changed the title Issue #18470: Fix PMD CI config Issue #18470: Activate PMD gatekeeper Jan 11, 2026
@Pankraz76

Copy link
Copy Markdown
Author
image

@romani

please execute PMD locally the correct way!!

RIGHT!!!

./mvnw -e --no-transfer-progress clean pmd:check

WRONG !!!

./mvnw -e --no-transfer-progress clean test-compile pmd:check

@romani

romani commented Jan 11, 2026

Copy link
Copy Markdown
Member

New pmd violations:
[�[1;33mWARNING�[m] PMD Failure: com.puppycrawl.tools.checkstyle.AbstractAutomaticBean:243 Rule:ExceptionAsFlowControl Priority:3 Exception thrown at line 237 is caught in this block..

PMD Failure: com.puppycrawl.tools.checkstyle.DetailNodeTreeStringPrinter:80 Rule:UnusedPrivateMethod Priority:3 Avoid unused private methods such as 'parseJavadocAsDetailNode(String)'..

@romani

romani commented Jan 11, 2026

Copy link
Copy Markdown
Member

CI job should stay as is we can do two mvn commands under ci command to run spotbugs and pmd separately

@Pankraz76

Copy link
Copy Markdown
Author

i dont think so. Why having this coupled for no reason?

please conaider dedication and seperation principle to see each job upfront like we for other SCA tool as well:

@Pankraz76

Copy link
Copy Markdown
Author

CI job should stay as is we can do two mvn commands under ci command to run spotbugs and pmd separately

yes kind of to fix now. but why having this coupling?

@Pankraz76

Copy link
Copy Markdown
Author

item:

Command: ./mvnw -e --no-transfer-progress clean pmd:check

New pmd violations:
[�[1;33mWARNING�[m] PMD Failure: com.puppycrawl.tools.checkstyle.AbstractAutomaticBean:243 Rule:ExceptionAsFlowControl Priority:3 Exception thrown at line 237 is caught in this block..

PMD Failure: com.puppycrawl.tools.checkstyle.DetailNodeTreeStringPrinter:80 Rule:UnusedPrivateMethod Priority:3 Avoid unused private methods such as 'parseJavadocAsDetailNode(String)'..

@Pankraz76 Pankraz76 changed the title Issue #18470: Activate PMD gatekeeper Issue #18470: Fix wrong test scope for PMD and spotbugs Jan 12, 2026
@Pankraz76 Pankraz76 marked this pull request as ready for review January 12, 2026 12:11
@Pankraz76

Copy link
Copy Markdown
Author

CI job should stay as is we can do two mvn commands under ci command to run spotbugs and pmd separately

yes now its your style. actually its just the test scope issue.

@Pankraz76 Pankraz76 changed the title Issue #18470: Fix wrong test scope for PMD and spotbugs Pull #18529: Fix wrong test scope for PMD and spotbugs #18470 Jan 12, 2026
Pankraz76 pushed a commit to Pankraz76/checkstyle that referenced this pull request Jan 12, 2026
@Pankraz76

Copy link
Copy Markdown
Author

item

01:58
[INFO] --- compiler:3.14.1:compile (default-compile) @ equalsverifier-testhelpers ---01:58
[INFO] Recompiling the module because of changed source code.01:59
[INFO] Compiling 83 source files with javac [forked debug release 17] to target/classes01:59
[INFO] -------------------------------------------------------------01:59
[ERROR] COMPILATION ERROR : 01:59
[INFO] -------------------------------------------------------------01:59
[ERROR] 	at jdk.compiler/com.sun.tools.javac.api.BasicJavacTask.initPlugins(BasicJavacTask.java:232)01:59
	at jdk.compiler/com.sun.tools.javac.main.Main.compile(Main.java:294)01:59
	at jdk.compiler/com.sun.tools.javac.main.Main.compile(Main.java:178)01:59
	at jdk.compiler/com.sun.tools.javac.Main.compile(Main.java:64)01:59
	at jdk.compiler/com.sun.tools.javac.Main.main(Main.java:50)01:59
Caused by: com.google.errorprone.InvalidCommandLineOptionException: -XDaddTypeAnnotationsToSymbol=true is required by Error Prone on JDK 2101:59
	at com.google.errorprone.BaseErrorProneJavaCompiler.checkAddTypeAnnotationsToSymbol(BaseErrorProneJavaCompiler.java:243)01:59
	at com.google.errorprone.BaseErrorProneJavaCompiler.addTaskListener(BaseErrorProneJavaCompiler.java:91)01:59
	at com.google.errorprone.ErrorProneJavacPlugin.init(ErrorProneJavacPlugin.java:34)01:59
	at jdk.compiler/com.sun.tools.javac.api.BasicJavacTask.initPlugin(BasicJavacTask.java:256)01:59
	at jdk.compiler/com.sun.tools.javac.api.BasicJavacTask.initPlugins(BasicJavacTask.java:230)01:59
	... 4 more01:59
[INFO] 1 error01:59
[INFO] ----------------------------------

@romani romani left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Items

Comment thread .ci/validation.sh
Comment thread config/pmd.xml
<exclude name="DataClass"/>
<!-- Too many alarms on the check classes, we will never move logic out of the check,
each check is an independent logic container. -->
<exclude name="ExceptionAsFlowControl"/>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You might share it before.
Please share one more time violation that we suppressing I need to double check

@Pankraz76 Pankraz76 Jan 13, 2026

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you also found it

[�[1;33mWARNING�[m] PMD Failure: com.puppycrawl.tools.checkstyle.
AbstractAutomaticBean:243 Rule:ExceptionAsFlowControl Priority:3 
Exception thrown at line 237 is caught in this block..

lets just go. in PMD we trust.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, this rule is not working well, ok to disable

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no the rule is working fine kind of, but its the way its done in java since day one.

isnt´t it? @adangel

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know what you mean with "its done in java since day one"...

So, PMD claims that

catch (final InvocationTargetException | IllegalAccessException
catches the exception thrown at . If that is true, then this would be indeed an instance of ExceptionAsFlowControl.

But this doesn't look to be the case:

public class CheckstyleException extends Exception {
is just an Exception and not related to any of "InvocationTargetException | IllegalAccessException | NoSuchMethodException".

This leads to the conclusion: Either PMD is wrong or PMD is not called correctly. I suspect that latter, as figuring out the relation of types requires a correct auxclasspath, see the comment above in "validation.sh".

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know what you mean with "its done in java since day one"...

Being in the industry for 15 years, i learned from day one Exception As Flow Control is bad, still it was done every since in all the codebases around.

So PMD is correctly working, yes.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if this is so fragile then better extract the tool calls to avoid any unwanted interconnection.

actually consider the comment it feels strange that PMD and spot are connected even the commen stated it needs to run alone.

coupling is always bad software design so lets avoid in CI as well.

Pankraz76 pushed a commit to Pankraz76/checkstyle that referenced this pull request Jan 13, 2026
Pankraz76 pushed a commit to Pankraz76/checkstyle that referenced this pull request Jan 14, 2026
@Pankraz76

Copy link
Copy Markdown
Author

rdy 2 merge.

@Pankraz76

Copy link
Copy Markdown
Author

lets fix and pick this low hanging fruit @romani

@romani

romani commented Jan 18, 2026

Copy link
Copy Markdown
Member

please do #18529 (comment)

Comment thread .ci/validation.sh Outdated
CHECKSTYLE_DIR=$(pwd)
export MAVEN_OPTS='-Xmx2g'
./mvnw -e --no-transfer-progress clean test-compile pmd:check spotbugs:check
./mvnw -e --no-transfer-progress clean pmd:check spotbugs:check

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This call of pmd and spotbugs most likely won't work correctly now: PMD and spotbugs require that the project under analysis is compiled. These tools need access to the bytecode (aka. auxclasspath). Hence there was "test-compile" added before...
Without this, these tools could produce false positive and/or negatives.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

with this the tool did not worked properly ether, so its kind of strange, as the copse was limited to test.

rewrite is able to call the compile phase itself is this something PMD can adjust as well? this is kind of error prone.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if this is important then we should call both compile goals, which would hopefully also fix the scope issue.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This call of pmd and spotbugs most likely won't work correctly now: PMD and spotbugs require that the project under analysis is compiled. These tools need access to the bytecode (aka. auxclasspath). Hence there was "test-compile" added before... Without this, these tools could produce false positive and/or negatives.

idk but actually adding the compile phase is in both cases wrong having tried it only the one WITHOUT is failing like expected to call PMD just like rewrite tool:goal without any prefix goal imposing unwanted coupling and config burden to user;

image

@Pankraz76

Copy link
Copy Markdown
Author

lets merge. Looking into the facts PMD is working fine, as without the change its definitely not good working not at all.

Pankraz76 pushed a commit to Pankraz76/checkstyle that referenced this pull request Jan 20, 2026
@Pankraz76 Pankraz76 requested a review from adangel January 20, 2026 11:22
Comment thread .ci/validation.sh Outdated
export MAVEN_OPTS='-Xmx2g'
./mvnw -e --no-transfer-progress clean test-compile pmd:check spotbugs:check
./mvnw -e --no-transfer-progress clean pmd:check
./mvnw -e --no-transfer-progress clean spotbugs:check

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

only spot bugs need this ....

@Pankraz76 Pankraz76 changed the title Pull #18529: Fix wrong test scope for PMD and spotbugs #18470 Pull #18529: Fix wrong test scope for PMD #18470 Jan 20, 2026

@romani romani left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am ok to run tools separately.

They are too advanced now and conflicting with each other or with previous tools (jacoco).

checker, pitest, error-prone already fully separate.

@romani romani merged commit 23715ef into checkstyle:master Jan 20, 2026
119 checks passed
@romani romani changed the title Pull #18529: Fix wrong test scope for PMD #18470 Pull #18529: Fix wrong test scope for PMD Jan 20, 2026
@github-actions github-actions Bot added this to the 13.1.0 milestone Jan 20, 2026
@Pankraz76

Copy link
Copy Markdown
Author

I am ok to run tools separately.

then suggest to fully split. not only in some command.

@romani

romani commented Jan 20, 2026

Copy link
Copy Markdown
Member

No , same CI Job, two tasks in it.
Container starting time is longer than action execution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants