You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by "vishesh92 (via GitHub)" <gi...@apache.org> on 2026/05/15 11:53:46 UTC

[PR] Update pmd config to make it pmd 7 compatible [cloudstack]

vishesh92 opened a new pull request, #13168:
URL: https://github.com/apache/cloudstack/pull/13168

   ### Description
   
   This PR updates pmd config to make it pmd 7 compatible
   
   Ref: https://docs.pmd-code.org/pmd-doc-7.0.0-rc2/pmd_rules_java.html#best-practices
   
   <!--- Describe your changes in DETAIL - And how has behaviour functionally changed. -->
   
   <!-- For new features, provide link to FS, dev ML discussion etc. -->
   <!-- In case of bug fix, the expected and actual behaviours, steps to reproduce. -->
   
   <!-- When "Fixes: #<id>" is specified, the issue/PR will automatically be closed when this PR gets merged -->
   <!-- For addressing multiple issues/PRs, use multiple "Fixes: #<id>" -->
   <!-- Fixes: # -->
   
   <!--- ******************************************************************************* -->
   <!--- NOTE: AUTOMATION USES THE DESCRIPTIONS TO SET LABELS AND PRODUCE DOCUMENTATION. -->
   <!--- PLEASE PUT AN 'X' in only **ONE** box -->
   <!--- ******************************************************************************* -->
   
   ### Types of changes
   
   - [ ] Breaking change (fix or feature that would cause existing functionality to change)
   - [ ] New feature (non-breaking change which adds functionality)
   - [ ] Bug fix (non-breaking change which fixes an issue)
   - [ ] Enhancement (improves an existing feature and functionality)
   - [ ] Cleanup (Code refactoring and cleanup, that may add test cases)
   - [ ] Build/CI
   - [ ] Test (unit or integration test code)
   
   ### Feature/Enhancement Scale or Bug Severity
   
   #### Feature/Enhancement Scale
   
   - [ ] Major
   - [ ] Minor
   
   #### Bug Severity
   
   - [ ] BLOCKER
   - [ ] Critical
   - [ ] Major
   - [ ] Minor
   - [ ] Trivial
   
   ### Screenshots (if appropriate):
   
   ### How Has This Been Tested?
   
   <!-- Please describe in detail how you tested your changes. -->
   <!-- Include details of your testing environment, and the tests you ran to -->
   
   #### How did you try to break this feature and the system with this change?
   
   <!-- see how your change affects other areas of the code, etc. -->
   
   <!-- Please read the [CONTRIBUTING](https://github.com/apache/cloudstack/blob/main/CONTRIBUTING.md) document -->
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Update pmd config to make it pmd 7 compatible [cloudstack]

Posted by "vishesh92 (via GitHub)" <gi...@apache.org>.
vishesh92 commented on code in PR #13168:
URL: https://github.com/apache/cloudstack/pull/13168#discussion_r3266050739


##########
tools/checkstyle/src/main/resources/cloud-pmd.xml:
##########
@@ -23,59 +23,88 @@
   xmlns="http://pmd.sourceforge.net/ruleset/2.0.0">
 
   <description>
-    Ruleset that brings all the rulesets we want from the pmd jar, because
-    the maven-pmd-plugin doesn't find them otherwise. This is also the place
-    to add our own future rulesets, if any.
+    CloudStack PMD ruleset. Enables all PMD 7 categories with
+    project-specific exclusions for rules that are too noisy
+    or incompatible with CloudStack conventions.
   </description>
 
-  <rule ref="category/java/basic.xml"/>
-  <rule ref="category/java/braces.xml"/>
-  <rule ref="category/java/clone.xml"/>
-  <rule ref="category/java/codesize.xml"/>
-  <rule ref="category/java/comments.xml">
-    <!-- We shouldn't limit the number of lines in the header of a class -->
-    <exclude name="CommentSize"/>
-    <exclude name="CommentRequired" />
+  <rule ref="category/java/bestpractices.xml">
+    <exclude name="AbstractClassWithoutAbstractMethod" />
+    <exclude name="GuardLogStatement" />
+    <!-- <exclude name="LiteralsFirstInComparisons" /> -->

Review Comment:
   I discussed this with @DaanHoogland offline. And he suggested to comment these for now and enable as per requirement going forward.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Update pmd config to make it pmd 7 compatible [cloudstack]

Posted by "DaanHoogland (via GitHub)" <gi...@apache.org>.
DaanHoogland merged PR #13168:
URL: https://github.com/apache/cloudstack/pull/13168


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Update pmd config to make it pmd 7 compatible [cloudstack]

Posted by "vishesh92 (via GitHub)" <gi...@apache.org>.
vishesh92 commented on PR #13168:
URL: https://github.com/apache/cloudstack/pull/13168#issuecomment-4487489069

   > Can we remove the commented excludes ? My only concern is that with enabling the entire category, would this lead to excessive checks making it a lot more restrictive?
   
   This PR is only fixing the pmd config. In future, we will have checks only which makes sense for CloudStack and eventually block the builds. Currently the number of issues are huge and it will take quite some time to fix it.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Update pmd config to make it pmd 7 compatible [cloudstack]

Posted by "DaanHoogland (via GitHub)" <gi...@apache.org>.
DaanHoogland commented on PR #13168:
URL: https://github.com/apache/cloudstack/pull/13168#issuecomment-5478154880

   @vishesh92 should we merge (and for what branch)?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Update pmd config to make it pmd 7 compatible [cloudstack]

Posted by "vishesh92 (via GitHub)" <gi...@apache.org>.
vishesh92 commented on PR #13168:
URL: https://github.com/apache/cloudstack/pull/13168#issuecomment-5596777754

   > @vishesh92 should we merge (and for what branch)?
   
   yes. Let's merge on 4.20 itself. This shouldn't break anything


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Update pmd config to make it pmd 7 compatible [cloudstack]

Posted by "vishesh92 (via GitHub)" <gi...@apache.org>.
vishesh92 commented on code in PR #13168:
URL: https://github.com/apache/cloudstack/pull/13168#discussion_r3266052961


##########
tools/checkstyle/src/main/resources/cloud-pmd.xml:
##########
@@ -23,59 +23,88 @@
   xmlns="http://pmd.sourceforge.net/ruleset/2.0.0">
 
   <description>
-    Ruleset that brings all the rulesets we want from the pmd jar, because
-    the maven-pmd-plugin doesn't find them otherwise. This is also the place
-    to add our own future rulesets, if any.
+    CloudStack PMD ruleset. Enables all PMD 7 categories with
+    project-specific exclusions for rules that are too noisy
+    or incompatible with CloudStack conventions.
   </description>
 
-  <rule ref="category/java/basic.xml"/>
-  <rule ref="category/java/braces.xml"/>
-  <rule ref="category/java/clone.xml"/>
-  <rule ref="category/java/codesize.xml"/>
-  <rule ref="category/java/comments.xml">
-    <!-- We shouldn't limit the number of lines in the header of a class -->
-    <exclude name="CommentSize"/>
-    <exclude name="CommentRequired" />
+  <rule ref="category/java/bestpractices.xml">
+    <exclude name="AbstractClassWithoutAbstractMethod" />
+    <exclude name="GuardLogStatement" />
+    <!-- <exclude name="LiteralsFirstInComparisons" /> -->
+    <!-- <exclude name="PreserveStackTrace" /> -->
+    <!-- <exclude name="AvoidReassigningParameters" /> -->
+    <!-- <exclude name="LooseCoupling" /> -->
+    <!-- <exclude name="UseCollectionIsEmpty" /> -->
+    <!-- <exclude name="MissingOverride" /> -->
+    <!-- <exclude name="UnusedAssignment" /> -->
   </rule>
-  <rule ref="category/java/controversial.xml">
-    <!-- The rule is good, but is not properly applied. It forces you to statically declare it as ConcurrentHashMap -->
-    <exclude name="UseConcurrentHashMap"/>
-    <exclude name="CallSuperInConstructor"/>
-    <exclude name="AtLeastOneConstructor"/>
-    <exclude name="AssignmentInOperand"/>
-    <exclude name="NullAssignment"/>
-    <exclude name="DataflowAnomalyAnalysis" />
-    <exclude name="UseObjectForClearerAPI" />
+
+  <rule ref="category/java/codestyle.xml">
+    <exclude name="ShortVariable" />
+    <exclude name="AtLeastOneConstructor" />
+    <exclude name="CallSuperInConstructor" />
+    <!-- <exclude name="LocalVariableCouldBeFinal" />
+    <exclude name="MethodArgumentCouldBeFinal" /> -->
+    <!-- <exclude name="OnlyOneReturn" /> -->
+    <!-- <exclude name="CommentDefaultAccessModifier" /> -->
+    <!-- <exclude name="FieldNamingConventions" /> -->
+    <!-- <exclude name="UseDiamondOperator" /> -->
+    <!-- <exclude name="UselessParentheses" /> -->
+    <!-- <exclude name="PrematureDeclaration" /> -->
+    <!-- <exclude name="UnnecessaryBoxing" /> -->
+    <!-- <exclude name="ControlStatementBraces" /> -->
+    <!-- <exclude name="FieldDeclarationsShouldBeAtStartOfClass" /> -->
+    <!-- <exclude name="ConfusingTernary" /> -->
+    <!-- <exclude name="UnnecessaryFullyQualifiedName" /> -->
+    <!-- <exclude name="LocalVariableNamingConventions" /> -->
+    <!-- <exclude name="UnnecessaryModifier" /> -->
+    <exclude name="LongVariable" />
   </rule>
-  <rule ref="category/java/coupling.xml">
+
+  <rule ref="category/java/design.xml">
     <exclude name="ExcessiveImports" />
     <exclude name="LawOfDemeter"/>
+    <!-- <exclude name="CyclomaticComplexity" /> -->
+    <!-- <exclude name="CognitiveComplexity" /> -->
+    <!-- <exclude name="NPathComplexity" /> -->
+    <!-- <exclude name="AvoidCatchingGenericException" /> -->
+    <!-- <exclude name="AvoidUncheckedExceptionsInSignatures" /> -->
+    <!-- <exclude name="ImmutableField" /> -->
+    <!-- <exclude name="NcssCount" /> -->
+    <!-- <exclude name="CollapsibleIfStatements" /> -->
+    <!-- <exclude name="MutableStaticState" />
+    <exclude name="CouplingBetweenObjects" />
+    <exclude name="TooManyMethods" />
+    <exclude name="GodClass" /> -->
   </rule>
-  <rule ref="category/java/design.xml">
+
+  <rule ref="category/java/documentation.xml">
+    <exclude name="CommentSize" />
+    <exclude name="CommentRequired" />
+  </rule>
+
+  <rule ref="category/java/errorprone.xml">

Review Comment:
   pmd checks are manual as of now, so it shouldn't break anything.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Update pmd config to make it pmd 7 compatible [cloudstack]

Posted by "Pearl1594 (via GitHub)" <gi...@apache.org>.
Pearl1594 commented on code in PR #13168:
URL: https://github.com/apache/cloudstack/pull/13168#discussion_r3265963354


##########
tools/checkstyle/src/main/resources/cloud-pmd.xml:
##########
@@ -23,59 +23,88 @@
   xmlns="http://pmd.sourceforge.net/ruleset/2.0.0">
 
   <description>
-    Ruleset that brings all the rulesets we want from the pmd jar, because
-    the maven-pmd-plugin doesn't find them otherwise. This is also the place
-    to add our own future rulesets, if any.
+    CloudStack PMD ruleset. Enables all PMD 7 categories with
+    project-specific exclusions for rules that are too noisy
+    or incompatible with CloudStack conventions.
   </description>
 
-  <rule ref="category/java/basic.xml"/>
-  <rule ref="category/java/braces.xml"/>
-  <rule ref="category/java/clone.xml"/>
-  <rule ref="category/java/codesize.xml"/>
-  <rule ref="category/java/comments.xml">
-    <!-- We shouldn't limit the number of lines in the header of a class -->
-    <exclude name="CommentSize"/>
-    <exclude name="CommentRequired" />
+  <rule ref="category/java/bestpractices.xml">
+    <exclude name="AbstractClassWithoutAbstractMethod" />
+    <exclude name="GuardLogStatement" />
+    <!-- <exclude name="LiteralsFirstInComparisons" /> -->

Review Comment:
   Can we remove these commented excludes?



##########
tools/checkstyle/src/main/resources/cloud-pmd.xml:
##########
@@ -23,59 +23,88 @@
   xmlns="http://pmd.sourceforge.net/ruleset/2.0.0">
 
   <description>
-    Ruleset that brings all the rulesets we want from the pmd jar, because
-    the maven-pmd-plugin doesn't find them otherwise. This is also the place
-    to add our own future rulesets, if any.
+    CloudStack PMD ruleset. Enables all PMD 7 categories with
+    project-specific exclusions for rules that are too noisy
+    or incompatible with CloudStack conventions.
   </description>
 
-  <rule ref="category/java/basic.xml"/>
-  <rule ref="category/java/braces.xml"/>
-  <rule ref="category/java/clone.xml"/>
-  <rule ref="category/java/codesize.xml"/>
-  <rule ref="category/java/comments.xml">
-    <!-- We shouldn't limit the number of lines in the header of a class -->
-    <exclude name="CommentSize"/>
-    <exclude name="CommentRequired" />
+  <rule ref="category/java/bestpractices.xml">
+    <exclude name="AbstractClassWithoutAbstractMethod" />
+    <exclude name="GuardLogStatement" />
+    <!-- <exclude name="LiteralsFirstInComparisons" /> -->
+    <!-- <exclude name="PreserveStackTrace" /> -->
+    <!-- <exclude name="AvoidReassigningParameters" /> -->
+    <!-- <exclude name="LooseCoupling" /> -->
+    <!-- <exclude name="UseCollectionIsEmpty" /> -->
+    <!-- <exclude name="MissingOverride" /> -->
+    <!-- <exclude name="UnusedAssignment" /> -->
   </rule>
-  <rule ref="category/java/controversial.xml">
-    <!-- The rule is good, but is not properly applied. It forces you to statically declare it as ConcurrentHashMap -->
-    <exclude name="UseConcurrentHashMap"/>
-    <exclude name="CallSuperInConstructor"/>
-    <exclude name="AtLeastOneConstructor"/>
-    <exclude name="AssignmentInOperand"/>
-    <exclude name="NullAssignment"/>
-    <exclude name="DataflowAnomalyAnalysis" />
-    <exclude name="UseObjectForClearerAPI" />
+
+  <rule ref="category/java/codestyle.xml">
+    <exclude name="ShortVariable" />
+    <exclude name="AtLeastOneConstructor" />
+    <exclude name="CallSuperInConstructor" />
+    <!-- <exclude name="LocalVariableCouldBeFinal" />
+    <exclude name="MethodArgumentCouldBeFinal" /> -->
+    <!-- <exclude name="OnlyOneReturn" /> -->
+    <!-- <exclude name="CommentDefaultAccessModifier" /> -->
+    <!-- <exclude name="FieldNamingConventions" /> -->
+    <!-- <exclude name="UseDiamondOperator" /> -->
+    <!-- <exclude name="UselessParentheses" /> -->
+    <!-- <exclude name="PrematureDeclaration" /> -->
+    <!-- <exclude name="UnnecessaryBoxing" /> -->
+    <!-- <exclude name="ControlStatementBraces" /> -->
+    <!-- <exclude name="FieldDeclarationsShouldBeAtStartOfClass" /> -->
+    <!-- <exclude name="ConfusingTernary" /> -->
+    <!-- <exclude name="UnnecessaryFullyQualifiedName" /> -->
+    <!-- <exclude name="LocalVariableNamingConventions" /> -->
+    <!-- <exclude name="UnnecessaryModifier" /> -->
+    <exclude name="LongVariable" />
   </rule>
-  <rule ref="category/java/coupling.xml">
+
+  <rule ref="category/java/design.xml">
     <exclude name="ExcessiveImports" />
     <exclude name="LawOfDemeter"/>
+    <!-- <exclude name="CyclomaticComplexity" /> -->
+    <!-- <exclude name="CognitiveComplexity" /> -->
+    <!-- <exclude name="NPathComplexity" /> -->
+    <!-- <exclude name="AvoidCatchingGenericException" /> -->
+    <!-- <exclude name="AvoidUncheckedExceptionsInSignatures" /> -->
+    <!-- <exclude name="ImmutableField" /> -->
+    <!-- <exclude name="NcssCount" /> -->
+    <!-- <exclude name="CollapsibleIfStatements" /> -->
+    <!-- <exclude name="MutableStaticState" />
+    <exclude name="CouplingBetweenObjects" />
+    <exclude name="TooManyMethods" />
+    <exclude name="GodClass" /> -->
   </rule>
-  <rule ref="category/java/design.xml">
+
+  <rule ref="category/java/documentation.xml">
+    <exclude name="CommentSize" />
+    <exclude name="CommentRequired" />
+  </rule>
+
+  <rule ref="category/java/errorprone.xml">

Review Comment:
   I'm guessing this wouldn't clash with the errorprone work which depends on google-errorprone plugin (mvn)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Update pmd config to make it pmd 7 compatible [cloudstack]

Posted by "codecov[bot] (via GitHub)" <gi...@apache.org>.
codecov[bot] commented on PR #13168:
URL: https://github.com/apache/cloudstack/pull/13168#issuecomment-4459571575

   ## [Codecov](https://app.codecov.io/gh/apache/cloudstack/pull/13168?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
   :white_check_mark: All modified and coverable lines are covered by tests.
   :white_check_mark: Project coverage is 4.15%. Comparing base ([`a7c2a05`](https://app.codecov.io/gh/apache/cloudstack/commit/a7c2a059f5d7517db78310bab48dcb2a6acd0924?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`be6b50c`](https://app.codecov.io/gh/apache/cloudstack/commit/be6b50c1687a543a8a864dd72b05065fde34141d?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
   > :exclamation:  There is a different number of reports uploaded between BASE (a7c2a05) and HEAD (be6b50c). Click for more details.
   > 
   > <details><summary>HEAD has 1 upload less than BASE</summary>
   >
   >| Flag | BASE (a7c2a05) | HEAD (be6b50c) |
   >|------|------|------|
   >|unittests|1|0|
   ></details>
   
   <details><summary>Additional details and impacted files</summary>
   
   
   
   ```diff
   @@              Coverage Diff              @@
   ##               4.20   #13168       +/-   ##
   =============================================
   - Coverage     16.27%    4.15%   -12.12%     
   =============================================
     Files          5665      404     -5261     
     Lines        500555    32966   -467589     
     Branches      60789     5893    -54896     
   =============================================
   - Hits          81445     1370    -80075     
   + Misses       410004    31420   -378584     
   + Partials       9106      176     -8930     
   ```
   
   | [Flag](https://app.codecov.io/gh/apache/cloudstack/pull/13168/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | |
   |---|---|---|
   | [uitests](https://app.codecov.io/gh/apache/cloudstack/pull/13168/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `4.15% <ø> (ø)` | |
   | [unittests](https://app.codecov.io/gh/apache/cloudstack/pull/13168/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
   
   Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#carryforward-flags-in-the-pull-request-comment) to find out more.
   </details>
   
   [:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/apache/cloudstack/pull/13168?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).   
   :loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
   <details><summary> :rocket: New features to boost your workflow: </summary>
   
   - :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems.
   - :package: [JS Bundle Analysis](https://docs.codecov.com/docs/javascript-bundle-analysis): Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
   </details>


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Update pmd config to make it pmd 7 compatible [cloudstack]

Posted by "DaanHoogland (via GitHub)" <gi...@apache.org>.
DaanHoogland commented on PR #13168:
URL: https://github.com/apache/cloudstack/pull/13168#issuecomment-4475523001

   @blueorangutn package


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org