-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpmd-rules.xml
More file actions
141 lines (133 loc) · 6.89 KB
/
Copy pathpmd-rules.xml
File metadata and controls
141 lines (133 loc) · 6.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
<?xml version="1.0"?>
<ruleset name="FlossWare Commons PMD Rules"
xmlns="http://pmd.sourceforge.net/ruleset/2.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://pmd.sourceforge.net/ruleset/2.0.0
https://pmd.sourceforge.io/ruleset_2_0_0.xsd">
<description>
Custom PMD ruleset for FlossWare Commons Java project.
Includes best practices, error-prone, design, code style,
multithreading, and performance rules with project-specific
exclusions tailored for a utility/commons library.
</description>
<!-- Best Practices -->
<rule ref="category/java/bestpractices.xml">
<!-- Allow abstract classes without abstract methods (common base class pattern used in this project) -->
<exclude name="AbstractClassWithoutAbstractMethod"/>
<!-- Permit JUnit5 assertions without messages when intent is clear -->
<exclude name="JUnitAssertionsShouldIncludeMessage"/>
<!-- Allow JUnit5 test methods without public modifier -->
<exclude name="JUnitTestsShouldIncludeAssert"/>
<!-- Project uses java.util.logging with its own LoggerUtil wrapper -->
<exclude name="GuardLogStatement"/>
<!-- Logger fields are added for consistency even before active use -->
<exclude name="UnusedPrivateField"/>
<!-- UseVarargs suggestions conflict with existing public API -->
<exclude name="UseVarargs"/>
<!-- Try-with-resources refactoring would change existing public API behavior -->
<exclude name="UseTryWithResources"/>
<!-- Package coupling is expected in a commons library -->
<exclude name="LoosePackageCoupling"/>
</rule>
<!-- Error Prone -->
<rule ref="category/java/errorprone.xml">
<!-- Allow empty catch blocks when variable is named 'expected' or 'ignore' -->
<exclude name="EmptyCatchBlock"/>
<!-- Avoid false positives on bean member accessors -->
<exclude name="BeanMembersShouldSerialize"/>
<!-- Duplicate string literals are common in utility classes with related constants -->
<exclude name="AvoidDuplicateLiterals"/>
<!-- Utility methods commonly use literals in conditions for guard clauses -->
<exclude name="AvoidLiteralsInIfCondition"/>
<!-- ClassLoader usage is intentional in utility/reflection methods -->
<exclude name="UseProperClassLoader"/>
</rule>
<!-- Re-include EmptyCatchBlock with custom config -->
<rule ref="category/java/errorprone.xml/EmptyCatchBlock">
<properties>
<property name="allowCommentedBlocks" value="true"/>
<property name="allowExceptionNameRegex" value="^(expected|ignore(d)?)$"/>
</properties>
</rule>
<!-- Design -->
<rule ref="category/java/design.xml">
<!-- This project uses deep inheritance for its base class pattern -->
<exclude name="ExcessiveClassLength"/>
<!-- Allow utility classes with longer method counts for comprehensive APIs -->
<exclude name="TooManyMethods"/>
<!-- Relax coupling constraints for utility/commons libraries -->
<exclude name="LawOfDemeter"/>
<!-- Allow broader exception types in utility methods -->
<exclude name="SignatureDeclareThrowsException"/>
<!-- Varargs methods may have higher NPath complexity -->
<exclude name="NPathComplexity"/>
<!-- Utility classes are designed to be comprehensive (GodClass false positive) -->
<exclude name="GodClass"/>
<!-- Commons library methods may need to throw broad exception types -->
<exclude name="AvoidThrowingRawExceptionTypes"/>
<!-- Package coupling is expected in commons/utility projects -->
<exclude name="LoosePackageCoupling"/>
</rule>
<!-- Re-include CyclomaticComplexity with a more permissive threshold -->
<rule ref="category/java/design.xml/CyclomaticComplexity">
<properties>
<property name="methodReportLevel" value="15"/>
<property name="classReportLevel" value="80"/>
</properties>
</rule>
<!-- Re-include CognitiveComplexity with a more permissive threshold -->
<rule ref="category/java/design.xml/CognitiveComplexity">
<properties>
<property name="reportLevel" value="20"/>
</properties>
</rule>
<!-- Code Style -->
<rule ref="category/java/codestyle.xml">
<!-- Allow longer variable names for descriptive naming -->
<exclude name="LongVariable"/>
<!-- Allow shorter variable names for lambdas and loop vars -->
<exclude name="ShortVariable"/>
<!-- Allow shorter method names -->
<exclude name="ShortMethodName"/>
<!-- Allow shorter class names -->
<exclude name="ShortClassName"/>
<!-- This project uses explicit 'this' for clarity -->
<exclude name="LocalVariableCouldBeFinal"/>
<!-- Allow method argument reassignment in builders/fluent APIs -->
<exclude name="MethodArgumentCouldBeFinal"/>
<!-- Conflicts with project's import ordering -->
<exclude name="UnnecessaryImport"/>
<!-- Project uses on-demand static imports in tests -->
<exclude name="TooManyStaticImports"/>
<!-- Permit calling super() explicitly for clarity -->
<exclude name="CallSuperInConstructor"/>
<!-- Allow use of default package access -->
<exclude name="CommentDefaultAccessModifier"/>
<!-- Allow fields at the top of the class before constructors -->
<exclude name="FieldDeclarationsShouldBeAtStartOfClass"/>
<!-- Package-private access is used intentionally -->
<exclude name="DefaultPackage"/>
<!-- Permit 'Unnecessary' modifiers in interfaces for clarity -->
<exclude name="UnnecessaryModifier"/>
<!-- AtLeastOneConstructor not required - default constructors are fine -->
<exclude name="AtLeastOneConstructor"/>
<!-- OnlyOneReturn is too restrictive for guard-clause patterns -->
<exclude name="OnlyOneReturn"/>
<!-- Method naming conventions in this project may not match return type linguistics -->
<exclude name="LinguisticNaming"/>
<!-- Underscores in numeric literals are optional for readability -->
<exclude name="UseUnderscoresInNumericLiterals"/>
<!-- Utility classes may merge identical catch branches for distinct error handling -->
<exclude name="IdenticalCatchBranches"/>
</rule>
<!-- Multithreading -->
<rule ref="category/java/multithreading.xml">
<!-- Allow non-thread-safe singletons in utility contexts -->
<exclude name="UseConcurrentHashMap"/>
</rule>
<!-- Performance -->
<rule ref="category/java/performance.xml">
<!-- FileInputStream/FileOutputStream usage is intentional in IO utilities -->
<exclude name="AvoidFileStream"/>
</rule>
</ruleset>