-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpmd-ruleset.xml
More file actions
118 lines (110 loc) · 7.46 KB
/
Copy pathpmd-ruleset.xml
File metadata and controls
118 lines (110 loc) · 7.46 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
<?xml version="1.0"?>
<ruleset name="jhelm 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>PMD ruleset for the jhelm project</description>
<!-- Best Practices -->
<rule ref="category/java/bestpractices.xml">
<exclude name="UnitTestContainsTooManyAsserts"/> <!-- was JUnitTestContainsTooManyAsserts before PMD 7.7 -->
<exclude name="UnitTestAssertionsShouldIncludeMessage"/> <!-- was JUnitAssertionsShouldIncludeMessage before PMD 7.7 -->
<exclude name="LooseCoupling"/>
<exclude name="AvoidReassigningLoopVariables"/> <!-- Go-style escape parsing in StringUtils -->
<exclude name="AvoidReassigningParameters"/> <!-- ChainNode follows Go template port pattern -->
<exclude name="UseVarargs"/> <!-- Changing method signatures could break API -->
<exclude name="LiteralsFirstInComparisons"/> <!-- Project prefers subject.equals(literal) readability -->
<exclude name="UnusedAssignment"/> <!-- False positives on field assignments in try/catch branches -->
<exclude name="SystemPrintln"/> <!-- CLI application uses System.out/err for user output -->
<exclude name="NonExhaustiveSwitch"/> <!-- Parser switch intentionally handles known token types only (moved from codestyle in PMD 7) -->
<exclude name="PreserveStackTrace"/> <!-- ExecutionException unwrapping uses getCause() intentionally (moved from errorprone in PMD 7) -->
<exclude name="RelianceOnDefaultCharset"/> <!-- GoTemplate API mirrors Go behavior; charset is not configurable -->
<exclude name="GuardLogStatement"/> <!-- SLF4J parameterized logging avoids the cost this rule guards against -->
<exclude name="ImplicitFunctionalInterface"/> <!-- False positive on interfaces extending multi-method parents; inconsistent across environments -->
<exclude name="UnnecessaryWarningSuppression"/> <!-- CloseResource fires on macOS but not Linux; meta-rule cascading failures -->
</rule>
<!-- Code Style -->
<rule ref="category/java/codestyle.xml">
<exclude name="AtLeastOneConstructor"/>
<exclude name="OnlyOneReturn"/>
<exclude name="LocalVariableCouldBeFinal"/>
<exclude name="MethodArgumentCouldBeFinal"/>
<exclude name="ShortVariable"/>
<exclude name="LongVariable"/>
<exclude name="ShortMethodName"/>
<exclude name="ShortClassName"/>
<exclude name="CommentDefaultAccessModifier"/>
<exclude name="CallSuperInConstructor"/>
<exclude name="ConfusingTernary"/>
<exclude name="TooManyStaticImports"/>
<exclude name="UseExplicitTypes"/>
<exclude name="UselessParentheses"/> <!-- Spring formatter controls parentheses style -->
<exclude name="FieldDeclarationsShouldBeAtStartOfClass"/> <!-- Function registries use inline fields -->
<exclude name="LinguisticNaming"/> <!-- Go template API mirrors Go naming (e.g., isBool, hasPrefix) -->
<exclude name="UseUnderscoresInNumericLiterals"/> <!-- Numeric constants match Go originals -->
<exclude name="ForLoopShouldBeWhileLoop"/> <!-- Lexer state machine uses for(;;) idiom -->
<exclude name="FieldNamingConventions"/> <!-- YAML/JSON deserialized models use snake_case field names -->
</rule>
<rule ref="category/java/codestyle.xml/ClassNamingConventions">
<properties>
<property name="utilityClassPattern" value="[A-Z][a-zA-Z0-9]*"/>
</properties>
</rule>
<!-- Design -->
<rule ref="category/java/design.xml">
<exclude name="ImmutableField"/> <!-- Picocli/Spring inject values into @Option/@Autowired fields -->
<exclude name="AvoidRethrowingException"/> <!-- Intentional rethrow before generic catch in plugin adapters -->
<exclude name="LawOfDemeter"/>
<exclude name="LoosePackageCoupling"/>
<exclude name="DataClass"/>
<exclude name="TooManyMethods"/>
<exclude name="ExcessiveImports"/>
<exclude name="CouplingBetweenObjects"/>
<exclude name="AvoidCatchingGenericException"/>
<exclude name="ExcessiveParameterList"/>
<exclude name="CyclomaticComplexity"/>
<exclude name="NcssCount"/>
<exclude name="NPathComplexity"/>
<exclude name="GodClass"/>
<exclude name="TooManyFields"/>
<exclude name="AvoidThrowingRawExceptionTypes"/>
<exclude name="SignatureDeclareThrowsException"/>
<exclude name="UseObjectForClearerAPI"/>
<exclude name="CognitiveComplexity"/> <!-- Lexer/Parser/Executor are state machines with inherent complexity -->
<exclude name="ExceptionAsFlowControl"/> <!-- ConversionFunctions uses try-catch for type parsing (Go port pattern) -->
<exclude name="SimplifyBooleanReturns"/> <!-- Sometimes explicit if/return reads more clearly -->
<exclude name="SimplifiedTernary"/> <!-- False positive on Object-typed returns with boolean false -->
<exclude name="AvoidUncheckedExceptionsInSignatures"/> <!-- Utility methods declare specific runtime exceptions -->
<exclude name="AvoidDeeplyNestedIfStmts"/> <!-- Complex loaders/resolvers require deep nesting -->
<exclude name="CollapsibleIfStatements"/> <!-- Separate conditions often read more clearly -->
<exclude name="AvoidThrowingNullPointerException"/> <!-- Lexer signals sentinel with NPE (Go port); moved from errorprone in PMD 7 -->
</rule>
<!-- Error Prone -->
<rule ref="category/java/errorprone.xml">
<exclude name="NonSerializableClass"/> <!-- was BeanMembersShouldSerialize before PMD 6.52 -->
<exclude name="DoNotTerminateVM"/> <!-- CLI application uses System.exit() for exit codes -->
<exclude name="AvoidLiteralsInIfCondition"/>
<exclude name="AvoidDuplicateLiterals"/>
<exclude name="MissingSerialVersionUID"/>
<exclude name="AvoidFieldNameMatchingMethodName"/>
<exclude name="AvoidFieldNameMatchingTypeName"/> <!-- Models/DTOs often have fields matching type names -->
<exclude name="NullAssignment"/>
<exclude name="ReturnEmptyCollectionRatherThanNull"/> <!-- Null signals "not found" in lookup methods -->
<exclude name="AvoidInstanceofChecksInCatchClause"/> <!-- Executor catch blocks pattern-match exception types -->
<exclude name="AssignmentInOperand"/> <!-- Standard I/O read-loop idiom -->
<exclude name="ConfusingArgumentToVarargsMethod"/> <!-- False positive on Object[] varargs lambdas -->
<exclude name="ReplaceJavaUtilDate"/> <!-- DateFunctions mirrors Go's date handling which uses Date objects -->
</rule>
<!-- Multithreading -->
<rule ref="category/java/multithreading.xml">
<exclude name="UseConcurrentHashMap"/>
<exclude name="DoNotUseThreads"/>
<exclude name="AvoidUsingVolatile"/> <!-- Volatile is appropriate for double-checked locking patterns -->
</rule>
<!-- Performance -->
<rule ref="category/java/performance.xml">
<exclude name="AvoidInstantiatingObjectsInLoops"/>
<exclude name="AvoidFileStream"/> <!-- FileInputStream/FileOutputStream are acceptable for file I/O -->
<exclude name="ConsecutiveAppendsShouldReuse"/> <!-- Chaining style is a preference -->
<exclude name="InsufficientStringBufferDeclaration"/> <!-- Premature optimization -->
</rule>
</ruleset>