Skip to content

[POC-FIX-PMD] maven-pmd-plugin: reactivate PMD - Best Practices #2331

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

@Pankraz76 Pankraz76 changed the title [POC] maven-pmd-plugin: Reintroduce PMD [POC] maven-pmd-plugin: reactivate PMD May 13, 2025
@Pankraz76
Copy link
Contributor Author

image
[INFO] --- pmd:3.26.0:check (maven-pmd-plugin) @ maven-api-core ---
[WARNING] PMD Failure: org.apache.maven.api.DependencyScope:100 Rule:UnnecessaryFullyQualifiedName Priority:4 Unnecessary qualifier 'DependencyScope': 'values' is already in scope.
[WARNING] PMD Failure: org.apache.maven.api.JavaPathType:222 Rule:UnnecessaryFullyQualifiedName Priority:4 Unnecessary qualifier 'JavaPathType': 'values' is already in scope.
[WARNING] PMD Failure: org.apache.maven.api.JavaPathType:262 Rule:UnnecessaryModifier Priority:3 Unnecessary modifier 'final' on method 'format': the method is already in a final class.
[WARNING] PMD Failure: org.apache.maven.api.MonotonicClock:59 Rule:UnnecessaryFullyQualifiedName Priority:4 Unnecessary qualifier 'Clock': 'systemUTC' is already in scope.
[WARNING] PMD Failure: org.apache.maven.api.services.ArtifactCoordinatesFactoryRequest:58 Rule:UnnecessaryFullyQualifiedName Priority:4 Unnecessary qualifier 'ArtifactCoordinatesFactoryRequest': 'builder' is already in scope.
[WARNING] PMD Failure: org.apache.maven.api.services.ArtifactCoordinatesFactoryRequest:76 Rule:UnnecessaryFullyQualifiedName Priority:4 Unnecessary qualifier 'ArtifactCoordinatesFactoryRequest': 'builder' is already in scope.
[WARNING] PMD Failure: org.apache.maven.api.services.ArtifactCoordinatesFactoryRequest:89 Rule:UnnecessaryFullyQualifiedName Priority:4 Unnecessary qualifier 'ArtifactCoordinatesFactoryRequest': 'builder' is already in scope.
[WARNING] PMD Failure: org.apache.maven.api.services.ArtifactCoordinatesFactoryRequest:97 Rule:UnnecessaryFullyQualifiedName Priority:4 Unnecessary qualifier 'ArtifactCoordinatesFactoryRequest': 'builder' is already in scope.
[WARNING] PMD Failure: org.apache.maven.api.services.ArtifactFactoryRequest:55 Rule:UnnecessaryFullyQualifiedName Priority:4 Unnecessary qualifier 'ArtifactFactoryRequest': 'builder' is already in scope.
[WARNING] PMD Failure: org.apache.maven.api.services.ArtifactFactoryRequest:72 Rule:UnnecessaryFullyQualifiedName Priority:4 Unnecessary qualifier 'ArtifactFactoryRequest': 'builder' is already in scope.
[WARNING] PMD Failure: org.apache.maven.api.services.DependencyCoordinatesFactoryRequest:62 Rule:UnnecessaryFullyQualifiedName Priority:4 Unnecessary qualifier 'DependencyCoordinatesFactoryRequest': 'builder' is already in scope.

@Pankraz76 Pankraz76 changed the title [POC] maven-pmd-plugin: reactivate PMD [POC] maven-pmd-plugin: reactivate PMD as recall from past to fullfill Disabled until projects have been made to comply May 13, 2025
@Pankraz76 Pankraz76 changed the title [POC] maven-pmd-plugin: reactivate PMD as recall from past to fullfill Disabled until projects have been made to comply ##### [POC-PMD-PRIO1] maven-pmd-plugin: reactivate PMD fullfill Disabled until projects have been made to comply May 13, 2025
@Pankraz76 Pankraz76 changed the title ##### [POC-PMD-PRIO1] maven-pmd-plugin: reactivate PMD fullfill Disabled until projects have been made to comply ##### [POC-PMD-PRIOR-1] maven-pmd-plugin: reactivate PMD fullfill Disabled until projects have been made to comply May 13, 2025
@Pankraz76 Pankraz76 changed the title ##### [POC-PMD-PRIOR-1] maven-pmd-plugin: reactivate PMD fullfill Disabled until projects have been made to comply [POC-PMD-PRIOR-1] maven-pmd-plugin: reactivate PMD fullfill Disabled until projects have been made to comply May 13, 2025
@Pankraz76 Pankraz76 changed the title [POC-PMD-PRIOR-1] maven-pmd-plugin: reactivate PMD fullfill Disabled until projects have been made to comply [POC-PMD-PRIOR-1] maven-pmd-plugin: reactivate PMD May 13, 2025
@Pankraz76 Pankraz76 changed the title [POC-PMD-PRIOR-1] maven-pmd-plugin: reactivate PMD [FIX-PMD] maven-pmd-plugin: reactivate PMD - minimumPriority 1 May 13, 2025
@Pankraz76 Pankraz76 changed the title [FIX-PMD] maven-pmd-plugin: reactivate PMD - minimumPriority 1 [FIX-PMD] maven-pmd-plugin: reactivate PMD - minimumPriority 1 May 13, 2025
@Pankraz76 Pankraz76 changed the title [FIX-PMD] maven-pmd-plugin: reactivate PMD - minimumPriority 1 [FIX-PMD] maven-pmd-plugin: reactivate PMD - **minimumPriority 1** May 13, 2025
@Pankraz76 Pankraz76 changed the title [FIX-PMD] maven-pmd-plugin: reactivate PMD - **minimumPriority 1** [FIX-PMD] maven-pmd-plugin: reactivate PMD - minimumPriority 1 May 13, 2025
@Pankraz76 Pankraz76 force-pushed the maven-pmd-plugin branch 2 times, most recently from 693b6f1 to 1c7544d Compare May 13, 2025 18:38
pom.xml Outdated
</plugin>
</plugins>
</pluginManagement>
<plugins>
<!-- why profile not working? -->
Copy link
Contributor Author

Choose a reason for hiding this comment

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

please why is it only applied when declared here?

@Pankraz76 Pankraz76 marked this pull request as ready for review May 13, 2025 18:50
@Pankraz76 Pankraz76 changed the title [FIX-PMD] maven-pmd-plugin: reactivate PMD - minimumPriority 1 [POC-FIX-PMD] maven-pmd-plugin: reactivate PMD - minimumPriority 2 May 13, 2025
@Pankraz76 Pankraz76 changed the title [POC-FIX-PMD] maven-pmd-plugin: reactivate PMD - minimumPriority 2 [POC-FIX-PMD] maven-pmd-plugin: reactivate PMD - minimumPriority 1 May 13, 2025
@Pankraz76 Pankraz76 marked this pull request as draft May 13, 2025 19:51
org.apache.maven.project.MavenProject=UnusedFormalParameter,CollapsibleIfStatements
org.apache.maven.slf4j.DefaultLogLevelRecorder=CollapsibleIfStatements,AvoidBranchingStatementAsLastInLoop
org.apache.maven.toolchain.building.DefaultToolchainsBuilder=UnusedFormalParameter
org.apache.maven.internal.xml.DefaultXmlService=UnusedPrivateMethod
Copy link
Contributor Author

@Pankraz76 Pankraz76 May 13, 2025

Choose a reason for hiding this comment

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

UnusedPrivateMethod this is why check and spot not enough.

@Pankraz76 Pankraz76 changed the title [POC-FIX-PMD] maven-pmd-plugin: reactivate PMD - minimumPriority 1 [POC-FIX-PMD] maven-pmd-plugin: reactivate PMD May 13, 2025
@Pankraz76 Pankraz76 changed the title [POC-FIX-PMD] maven-pmd-plugin: reactivate PMD [POC-FIX-PMD] maven-pmd-plugin: reactivate PMD - Best Practices May 13, 2025
@Pankraz76 Pankraz76 mentioned this pull request May 18, 2025
@slachiewicz
Copy link
Member

How was the excludes file generated?

@Pankraz76
Copy link
Contributor Author

Pankraz76 commented May 19, 2025

How was the excludes file generated?

AI/custom generated script, this feature is requested feature by PMD.

See here:

org.apache.maven.toolchain.building.DefaultToolchainsBuilder=UnusedFormalParameter,AvoidReassigningParameters
org.apache.maven.toolchain.java.JavaToolchainFactory=MissingOverride
org.apache.maven.toolchain.java.JavaToolchainImpl=MissingOverride
org.eclipse.sisu.plexus.PlexusXmlBeanConverter=MissingOverride,GuardLogStatement,PreserveStackTrace
Copy link
Contributor

Choose a reason for hiding this comment

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

not in the codebase

org.apache.maven.toolchain.java.JavaToolchainFactory=MissingOverride
org.apache.maven.toolchain.java.JavaToolchainImpl=MissingOverride
org.eclipse.sisu.plexus.PlexusXmlBeanConverter=MissingOverride,GuardLogStatement,PreserveStackTrace
org.fusesource.jansi.Ansi=AvoidStringBufferField,LooseCoupling,UseVarargs
Copy link
Contributor

Choose a reason for hiding this comment

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

not in the code base

Copy link
Contributor Author

Choose a reason for hiding this comment

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

why can PMD find it then?

@@ -0,0 +1,483 @@
org.apache.maven.AbstractMavenLifecycleParticipant=AbstractClassWithoutAbstractMethod
Copy link
Contributor

Choose a reason for hiding this comment

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

I am not sure that all of those (or even the majority) are actually in the code base.

If you want to add supressions, add `@SuppressWarnings("PMD.") statements at the places where the problems occur. That way, an IDE can pick them up and point out when a suppression is no longer needed.

Having a big central file is a sure recipe for this to fall into disrepair and things never getting fixed. Which is counter to what you are trying to accomplish.

Suppressions need to be applied surgically in the right place where a violation exist. Not as a blanked "We cover the whole class"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

place where a violation exist

is only possible doing it here. Other wise we have 500 operations inside the code thats impossible.

/*.svg
/**/.cache
Copy link
Contributor

Choose a reason for hiding this comment

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

Where is that needed and why would we ignore any .cache subfolder at any level of the tree?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes should be specific, but there is not collision so its not an big deal actually.

<excludeFromFailureFile>.pmd/exclude.properties</excludeFromFailureFile>
<printFailingErrors>true</printFailingErrors>
<rulesets>
<ruleset>category/java/bestpractices.xml</ruleset>
Copy link
Contributor

Choose a reason for hiding this comment

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

why would we not apply all java rulesets but only one?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

we can not pass even this one, so it might be overkill.

@hgschmie
Copy link
Contributor

This is not the right way to engage with this project. If you want to improve the code quality, we would be willing to review small, specific changes that solve an issue that exists. Not blanket, AI generated "here are large changes that are hard to verify" PRs without any context.

I will close this PR; feel free to resubmit smaller, better documented changes.

@hgschmie hgschmie closed this May 19, 2025
@Pankraz76
Copy link
Contributor Author

AI generated

at to silly for this simple task.

@Pankraz76
Copy link
Contributor Author

Pankraz76 commented May 20, 2025

smaller

will have issues (blindspots), not making it possible to activate the plugin.

We have blind spots or ignore 1o1 the errors.

This solution is very exact, as it only addresses existing issues not ignoring rules globally.

@Pankraz76
Copy link
Contributor Author

please tell me, how can we stop further violations? Freezing existing depth, not able to commit any more rubbish. @hgschmie

@Pankraz76
Copy link
Contributor Author

@bclozel @sdeleuze

would you guys appreciate an PMD legacy compatible integration on spring like seen here?

With my script created its easy to suppress all existing violations to prevent any further and then improve code quality from there, not committing corrupt code.

@Pankraz76
Copy link
Contributor Author

@cescoffier @geoand Would you like to adhere to Best Practices?

With this way we can prevent any new corruption from entering the code base.

@bclozel
Copy link

bclozel commented May 20, 2025

@Pankraz76 we don't use Maven in our projects, so I'm not sure why I'm being pinged here. I guess the answer is "no", then.

@Pankraz76
Copy link
Contributor Author

Pankraz76 commented May 20, 2025

its about PMD. Can be used via gradle too. https://docs.gradle.org/current/userguide/pmd_plugin.html As its Best Practices having to find large acceptance for comprehending minds.

@geoand
Copy link

geoand commented May 20, 2025

@cescoffier @geoand Would you like to adhere to Best Practices?

With this way we can prevent any new corruption from entering the code base.

@Pankraz76 I am not sure what you expect from us here.

@Pankraz76
Copy link
Contributor Author

If Maven does not care about norms, standardization, and following common sense, maybe Quarkus and Spring will. It's about avoiding overhead, reducing effort spent on avoidable issues, and focusing attention on the real business logic. We should not waste time on unused imports but on real progress being made.

So with this example given I would like to offer doing the same as its done by script now, giving ability to freeze technical dept.

I will shoot demo PR providing the same for Spring and Quarkus. Thus you can see the current situations and choose if you want more violations.

@geoand
Copy link

geoand commented May 20, 2025

@Pankraz76 I suggest taking a step and back and trying to ascertain how your changes and communication of said changes appears to project maintainers.

@Pankraz76
Copy link
Contributor Author

yes, i see this type of change is not simple to integrate. Thanks for feedback.

@geoand
Copy link

geoand commented May 20, 2025

👍🏽

@hgschmie
Copy link
Contributor

If Maven does not care about norms, standardization, and following common sense, maybe Quarkus and Spring will. It's about avoiding overhead, reducing effort spent on avoidable issues, and focusing attention on the real business logic. We should not waste time on unused imports but on real progress being made.

So with this example given I would like to offer doing the same as its done by script now, giving ability to freeze technical dept.

I will shoot demo PR providing the same for Spring and Quarkus. Thus you can see the current situations and choose if you want more violations.

@Pankraz76 This type of "you need to adhere to some imaginary standards or norms that I defined" comments don't work here. You need to ask yourself if that is a reasonable way to engage with any community, given the amount of pushback to your style of engagement that you have seen.

@Pankraz76
Copy link
Contributor Author

Pankraz76 commented May 20, 2025

Of course, my direct approach isn't very charming. I can only convince those who in favor of rules and reason—not those prioritize individual opinion or embrace the freedom of chaos (what some might call the broken window effect).

Some thrive in disorder, finding creativity in the absence of boundaries. For others, order is essential; they need structure to keep the marathon going.

P.S. This is the essence of law. There is no law without enforcement. These best practices serve the common good—they belong to no one, being defined by the community itself, in sync with Java Coding Conventions (JCC). Debating them in generell seems kind of goofy.

I didn't create, nor do I particularly care about these rules, even though they seem legitimate and reasonable. They seem the only valid foundation, making it obvious to integrate.

Java coding conventions come from Java itself, not from me. The same applies to PMD best practices—we can assure significant effort went into balancing these rules. Thus ends our endless debates about which rules are good or bad (though we've all participated eagerly).

That's the power of norms and standards. They're like syntax, but operating on a higher semantic plane. You all grasp this intuitively—while I remain, as ever, the least enlightened among us.

@geoand
Copy link

geoand commented May 20, 2025

Using ChatGPT (or friends) also doesn't do you any favors when trying to convince people...

@Pankraz76
Copy link
Contributor Author

Its my language given form and correction. Please stop horsing around. I spend 30 mins to create the post, yes im very special, taking my time.

Not everyone is so smart like you @geoand please excuse.

@geoand
Copy link

geoand commented May 20, 2025

The point I'm trying to make is very simple: you are putting effort into doing work but not taking feedback into account at all and continuing on a course that almost certainly leads to your work not having the impact you hope it has.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants