Repository navigation
Add final modifiers everywhere, enforced by PMD - #13
Conversation
872 final modifiers added (OpenRewrite FinalizeMethodArguments, FinalizeLocalVariables, FinalizePrivateFields and FinalClass, plus for-each variables and a few parameters by hand). Nothing else changed: with every final keyword and all whitespace removed, each file is identical to before. No parameter is reassigned anywhere, so none had to stay non-final. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
config/pmd/final-modifiers.xml enables MethodArgumentCouldBeFinal, LocalVariableCouldBeFinal, ImmutableField and ClassWithOnlyPrivateConstructorsShouldBeFinal; ./mvnw verify runs pmd:check over main and test sources and fails on any violation. The "could be final" rules ignore reassigned variables. The bulk final commit is added to .git-blame-ignore-revs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #13 +/- ##
=========================================
Coverage 99.65% 99.65%
Complexity 279 279
=========================================
Files 24 24
Lines 576 576
Branches 94 94
=========================================
Hits 574 574
Partials 2 2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 0 |
| Duplication | 8 |
AI Reviewer: first review requested successfully. AI can make mistakes. Always validate suggestions.
TIP This summary will be updated as you push new changes.
There was a problem hiding this comment.
Pull Request Overview
✅ No blocking issues noticed
No blocking findings were identified. The remaining gap is that PMD enforcement scenarios are not covered by automated build or fixture tests, including verification for both production and test sources.
About this PR
- Consider adding automated build-fixture or integration tests that verify each required final-modifier rule and confirm PMD runs against both production and test sources.
Test suggestions
- Existing algorithm and data-structure behavior remains unchanged after modifier-only changes.
- A missing final parameter is detected by the PMD build.
- A missing final local variable is detected by the PMD build.
- A missing final field is detected by the PMD build.
- A static-only class made non-final is detected by the PMD build.
- PMD enforcement applies to test sources as well as production sources.
Prompt proposal for missing tests
Consider implementing these tests if applicable:
1. A missing final parameter is detected by the PMD build.
2. A missing final local variable is detected by the PMD build.
3. A missing final field is detected by the PMD build.
4. A static-only class made non-final is detected by the PMD build.
5. PMD enforcement applies to test sources as well as production sources.
Make this review better
TIP Add a ticket key to the branch or title so the reviewer can check the PR against it. Or tell us which ticket tracker you use here.
TIP Add Codacy review.md instructions or an AGENTS.md so the reviewer knows your conventions.
TIP How was this review? Give us feedback
|
|
||
| public static boolean isRectangleTriangle(double a, double b, double c) { | ||
| double[] array = new double[3]; | ||
| public static boolean isRectangleTriangle(final double a, final double b, final double c) { |
There was a problem hiding this comment.
🟡 MEDIUM RISK
Suggestion: The two triangle helpers duplicate the array construction and sorting logic. Extract a private helper that returns the sorted sides, then reuse it in both methods to reduce maintenance risk.
TIP React 👍 if this review is right, or reply with what's wrong and how it could be better to help improve the reviewer.
Clean-code PR B of 4 (formatting ✅ →
final→ Javadoc → approved findings).Commits
5c6d4e9Addfinal: 872 modifiers across 108 files (library and problems).final varin problems and for-each variables (Q3).FinalizeMethodArguments,FinalizeLocalVariables,FinalizePrivateFields,FinalClass), plus for-each variables and a handful of parameters by hand.finalkeyword and all whitespace removed, each file is identical to before (872 added, 0 removed).418b1ceEnforce with PMD:config/pmd/final-modifiers.xmlwith four rules:MethodArgumentCouldBeFinal,LocalVariableCouldBeFinal,ImmutableFieldandClassWithOnlyPrivateConstructorsShouldBeFinal.maven-pmd-plugin3.28.0 with PMD 7.29.0.pmd:checkruns inverifyover main and test sources and fails on any violation.finalmakes./mvnw verifyfail ("PMD has found 1 violation")..git-blame-ignore-revs..git-blame-ignore-revshash stays valid.Codacy (manual step for you)
In Codacy →
algorithms-java→ Code patterns → PMD, turn on the same four patterns so PR comments match the build:Test plan
./mvnw verify: 591 tests, Spotless, PMD and coverage floors all pass🤖 Generated with Claude Code