Hi devs,
In the context of Loading... , I’ve done a quick review of our checkstyle config with the help of a LLM, to review:
- The status of the commented out checks we have in our config file
- To see if we could add some more
In both cases, I’ve asked the LLM to run the mvn command and report how many failures found to help us choose low hanging fruits.
Here’s the result:
Complete Table: All 35 Tested Checkstyle Checks Across XWiki Projects
| Check Name | Category | xwiki-commons | xwiki-rendering | xwiki-platform | Currently in Config | Notes |
|---|---|---|---|---|---|---|
| COMMENTED-OUT CHECKS | ||||||
| AvoidInlineConditionals | Coding | 5 | 0 | 116 | Commented | Ternary operators |
| ArrayTrailingComma | Coding | 0 | 0 | 0 | Commented | |
| ClassDataAbstractionCoupling | Metrics | 25 | 0 | 6 | Commented (lines 113-116) | High coupling in commons crypto/xml |
| DesignForExtension | Design | 32 | 0 | 954 | Commented | Major effort for platform |
| FinalLocalVariable | Coding | 114 | 0 | 1,675 | Commented | Very high effort, especially platform |
| FinalParameters | Misc | 153 | 0 | 3,276 | Commented | Highest violation count on platform |
| IllegalCatch | Coding | 8 | 0 | 95 | Commented | Catching Exception/Throwable |
| InterfaceIsType | Design | 0 | 0 | 0 | Commented | |
| MagicNumber | Coding | 1 | 0 | 129 | Commented | Low in commons, high in platform |
| MissingCtor | Coding | 14 | 0 | 231 | Commented | Moderate effort for platform |
| UnnecessaryParentheses | Coding | 3 | 0 | 55 | Commented | Low/moderate violations |
| SuperClone | Coding | 0 | 0 | 2 | Commented | Minimal violations |
| ThrowsCount | Design | 0 | 0 | 0 | Commented | |
| ImportOrder | Imports | 35 | 0 | 1,143 | Commented | Major effort for platform |
| RequireThis | Coding | 0 | 0 | 0 | Commented | |
| JavadocPackage | Javadoc | 30 | 0 | 0 | Commented | Only commons has violations (8 tool packages) |
| StrictDuplicateCode | N/A | N/A | N/A | N/A | Commented (lines 53-55) | |
| NEW CHECKS - GENERAL | ||||||
| EmptyCatchBlock | Blocks | 0 | 0 | 0 | Not in config | |
| EqualsAvoidNull | Coding | 0 | 0 | 14 | Not in config | Low violations on platform only |
| OneStatementPerLine | Coding | 0 | 0 | 0 | Not in config | |
| OverloadMethodsDeclarationOrder | Coding | 0 | 0 | 28 | Not in config | Low violations on platform only |
| UnusedLocalVariable | Coding | 0 | 0 | 1 | Not in config | Minimal violation |
| OneTopLevelClass | Design | 0 | 0 | 2 | Not in config | Minimal violation |
| InnerTypeLast | Design | 0 | 0 | 97 | Not in config | Moderate violations on platform |
| EmptyLineSeparator | Whitespace | 0 | 0 | 498 | Not in config | High violations on platform |
| NoLineWrap | Whitespace | 0 | 0 | 0 | Not in config | |
| AvoidDoubleBraceInitialization | Coding | 0 | 0 | 4 | Not in config | Minimal violation |
| LambdaParameterName | Naming | 0 | 0 | 0 | Not in config | |
| IllegalIdentifierName | Naming | 0 | 0 | 0 | Not in config | |
| NEW CHECKS - MODERN | ||||||
| AtclauseOrder | Javadoc | 1 | 0 | 0 | Not in config | Minimal violation in commons only |
| JavadocBlockTagLocation | Javadoc | 0 | 0 | 0 | Not in config | |
| InvalidJavadocPosition | Javadoc | 0 | 0 | 0 | Not in config | |
| AvoidNoArgumentSuperConstructorCall | Coding | 0 | 0 | 13 | Not in config | Low violations on platform only |
| CatchParameterName | Naming | 0 | 0 | 1 | Not in config | Minimal violation |
| NoWhitespaceBeforeCaseDefaultColon | Whitespace | 0 | 0 | 0 | Not in config |
Summary Statistics Across All Projects
Checks with Zero Violations on ALL Projects (14 checks): ![]()
- ArrayTrailingComma
- InterfaceIsType
- ThrowsCount
- RequireThis
- EmptyCatchBlock
- OneStatementPerLine
- NoLineWrap
- LambdaParameterName
- IllegalIdentifierName
- JavadocBlockTagLocation
- InvalidJavadocPosition
- NoWhitespaceBeforeCaseDefaultColon
Note: StrictDuplicateCode is invalid and should be removed.
Plus on commons/rendering only:
- AtclauseOrder (only 1 violation in commons)
Checks with Minimal Violations (1-14 total across all projects - 10 checks):
- AtclauseOrder (1)
- SuperClone (2)
- OneTopLevelClass (2)
- UnusedLocalVariable (1)
- CatchParameterName (1)
- AvoidDoubleBraceInitialization (4)
- EqualsAvoidNull (14)
- AvoidNoArgumentSuperConstructorCall (13)
Breakdown by Project
xwiki-commons (Current Project)
- Zero violations: 23 checks (66%)
- 1-10 violations: 5 checks (14%)
- 11-50 violations: 5 checks (14%)
- 100+ violations: 2 checks (6%)
xwiki-rendering
- Zero violations: 34 checks (97%)
- Notes: Rendering maintains very strict code quality; many files excluded from checkstyle
xwiki-platform (Largest Codebase)
- Zero violations: 14 checks (40%)
- 1-100 violations: 11 checks (31%)
- 100-1000 violations: 6 checks (17%)
- 1000+ violations: 4 checks (11%)
Platform’s Highest Violations:
- FinalParameters: 3,276 violations
- FinalLocalVariable: 1,675 violations
- ImportOrder: 1,143 violations
- DesignForExtension: 954 violations
- EmptyLineSeparator: 498 violations
Final Recommendations (Prioritized Across All Projects)
Tier 1: Enable Immediately Across All Projects
(14 checks, 0 violations everywhere)
These can be enabled with zero code changes across all three projects:
<!-- Add to TreeWalker section in checkstyle.xml -->
<module name="EmptyCatchBlock"/>
<module name="OneStatementPerLine"/>
<module name="NoLineWrap"/>
<module name="LambdaParameterName"/>
<module name="IllegalIdentifierName"/>
<module name="JavadocBlockTagLocation"/>
<module name="InvalidJavadocPosition"/>
<module name="NoWhitespaceBeforeCaseDefaultColon"/>
<!-- Uncomment existing checks -->
<module name="ArrayTrailingComma"/>
<module name="InterfaceIsType"/>
<module name="ThrowsCount"/>
<module name="RequireThis">
<property name="checkMethods" value="false"/>
</module>
Tier 2: Enable After Minimal Fixes (1-14 violations across all projects - 10 checks)
Priority Order:
- AtclauseOrder (1 violation) - Fix 1 Javadoc in commons
- CatchParameterName (1 violation) - Fix 1 parameter name in platform
- UnusedLocalVariable (1 violation) - Remove 1 unused variable in platform
- SuperClone (2 violations) - Fix 2 clone methods in platform
- OneTopLevelClass (2 violations) - Move 2 classes in platform
- AvoidDoubleBraceInitialization (4 violations) - Refactor 4 instances in platform
- AvoidNoArgumentSuperConstructorCall (13 violations) - Remove 13 unnecessary super() calls in platform
- EqualsAvoidNull (14 violations) - Reverse 14 string comparisons in platform
Tier 3: Enable Per-Project with Moderate Planning
Commons-specific (low effort):
- JavadocPackage (30) - Add package-info.java to 8 tool packages
- ClassDataAbstractionCoupling (25) - Refactor 6 complex classes
Platform-specific (moderate-high effort):
- OverloadMethodsDeclarationOrder (28)
- UnnecessaryParentheses (55)
- InnerTypeLast (97)
- IllegalCatch (95)
- AvoidInlineConditionals (116)
- MagicNumber (129)
- MissingCtor (231)
- EmptyLineSeparator (498)
Tier 4: Requires Major Cross-Project Effort (Defer or Phased Approach)
These require significant refactoring across multiple projects:
- DesignForExtension (commons: 32, platform: 954)
- ImportOrder (commons: 35, platform: 1,143) - Requires import style configuration
- FinalLocalVariable (commons: 114, platform: 1,675)
- FinalParameters (commons: 153, platform: 3,276)
Recommendation: Consider if these style-only checks justify the massive effort, or implement gradually with suppression for existing code.
I propose implementing Tier 1 right now and then do Tier 2.
WDYT?
Thanks