-
Notifications
You must be signed in to change notification settings - Fork 2
/
pmd_config.xml
138 lines (129 loc) · 6.66 KB
/
pmd_config.xml
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
<?xml version="1.0"?>
<ruleset name="Default rules" xmlns="http://pmd.sf.net/ruleset/2.0.0">
<description>
some hopefully sensible rule set
</description>
<rule ref="category/java/bestpractices.xml">
<exclude name="JUnitTestsShouldIncludeAssert" /> <!-- contradicts usage of private check methods -->
<exclude name="MethodReturnsInternalArray" /> <!-- we decide if we want that -->
<exclude name="AccessorClassGeneration" /> <!-- singleton -->
<exclude name="ArrayIsStoredDirectly" /> <!-- different opinion -->
<exclude name="AbstractClassWithoutAbstractMethod" /> <!-- we want more explicit naming -->
<exclude name="AvoidStringBufferField" /> <!-- some classes need to build a text report -->
</rule>
<rule
ref="category/java/bestpractices.xml/JUnitTestContainsTooManyAsserts">
<properties>
<property name="maximumAsserts" value="15" />
</properties>
</rule>
<rule ref="category/java/codestyle.xml">
<exclude name="DefaultPackage" />
<exclude name="CommentDefaultAccessModifier" />
<exclude name="MethodArgumentCouldBeFinal" />
<exclude name="LocalVariableCouldBeFinal" />
<exclude name="OnlyOneReturn" />
<exclude name="AtLeastOneConstructor" />
<exclude name="CallSuperInConstructor" /> <!-- no information gained by it -->
<exclude name="AbstractNaming" /> <!-- ugly to speak about this AbstractRule in this AbstractCategory -->
<exclude name="ShortVariable" /> <!-- want those in lambdas -->
<exclude name="AvoidFinalLocalVariable" /> <!-- contradicts "define everything in the minimal scope" -->
<exclude name="GenericsNaming" /> <!-- understanding complex generics requires speaking names -->
<exclude name="EmptyMethodInAbstractClassShouldBeAbstract" /> <!--optional callback methods -->
<exclude name="ShortMethodName" /> <!-- fluent API might want methods like "of" -->
</rule>
<rule ref="category/java/codestyle.xml/ClassNamingConventions">
<properties>
<property name="classPattern" value="[A-Z][a-zA-Z0-9]+" /> <!-- sometimes numbers are meant -->
<property name="abstractClassPattern" value="[A-Z][a-zA-Z0-9]+" />
<property name="interfacePattern" value="[A-Z][a-zA-Z0-9]+" />
<property name="utilityClassPattern" value="[A-Z][a-zA-Z0-9]+" /> <!-- naming should follow purpose -->
</properties>
</rule>
<rule ref="category/java/codestyle.xml/LongVariable">
<properties>
<property name="minimum" value="45" /> <!-- understandable names before shortness -->
</properties>
</rule>
<rule ref="category/java/codestyle.xml/TooManyStaticImports">
<properties>
<property name="maximumStaticImports" value="15" /> <!-- thinking of hamcrest matchers -->
</properties>
</rule>
<rule ref="category/java/codestyle.xml/ShortClassName">
<properties>
<property name="minimum" value="4" />
</properties>
</rule>
<rule ref="category/java/design.xml">
<exclude name="LawOfDemeter" /> <!-- fluent API -->
<exclude name="LoosePackageCoupling" /> <!-- requires specific configuration -->
<exclude name="SignatureDeclareThrowsException" /> <!-- TODO: specify different rules for test and exclude it only there -->
<exclude name="AvoidCatchingGenericException" /> <!-- at system boundaries, we want to send a code to the client -->
<exclude name="UseObjectForClearerAPI" /> <!-- too restrictive, not configurable -->
<exclude name="DataClass" /> <!-- contradicts rule above -->
<exclude name="GodClass" /> <!-- too restrictive, not configurable -->
<exclude name="AvoidRethrowingException" /> <!-- not compatible with some lambdas -->
</rule>
<rule ref="category/java/design.xml/AvoidDeeplyNestedIfStmts">
<properties>
<property name="problemDepth" value="4" /> <!-- too many not so complex methods were marked -->
</properties>
</rule>
<rule ref="category/java/design.xml/NcssCount">
<properties>
<property name="methodReportLevel" value="40" />
<property name="classReportLevel" value="600" />
</properties>
</rule>
<rule ref="category/java/design.xml/TooManyMethods">
<properties>
<property name="maxmethods" value="30" />
</properties>
</rule>
<rule ref="category/java/design.xml/CyclomaticComplexity">
<properties>
<property name="methodReportLevel" value="12" />
<property name="classReportLevel" value="100" />
</properties>
</rule>
<rule ref="category/java/design.xml/NPathComplexity">
<properties>
<property name="reportLevel" value="300" />
</properties>
</rule>
<rule ref="category/java/documentation.xml">
<exclude name="CommentSize" />
</rule>
<rule ref="category/java/documentation.xml/CommentRequired">
<properties>
<property name="fieldCommentRequirement" value="Ignored" />
</properties>
</rule>
<rule ref="category/java/errorprone.xml">
<exclude name="AvoidLiteralsInIfCondition" /> <!-- magic number check done with other rules, false positives -->
<exclude name="AvoidCatchingThrowable" /> <!-- at system boundaries, we want to send a code to the client or die trying -->
<exclude name="NullAssignment" /> <!-- nulling object might be wanted -->
<exclude name="ReturnEmptyArrayRatherThanNull" /> <!-- that's a semantic question -->
<exclude name="CloneThrowsCloneNotSupportedException" /> <!-- declare only exceptions which are really thrown -->
<exclude name="ProperCloneImplementation" /> <!-- too many false positives -->
</rule>
<rule ref="category/java/errorprone.xml/AvoidDuplicateLiterals">
<properties>
<property name="maxDuplicateLiterals" value="6" />
<property name="minimumLength" value="5" />
<property name="skipAnnotations" value="true" />
</properties>
</rule>
<rule ref="category/java/multithreading.xml">
<exclude name="UseConcurrentHashMap"></exclude> <!-- false positives -->
<exclude name="AvoidSynchronizedAtMethodLevel" /> <!-- developer decides which block to synchronize -->
<exclude name="AvoidUsingVolatile" /> <!-- developer decides about the need -->
</rule>
<rule ref="category/java/performance.xml">
<exclude name="AvoidFileStream" /> <!-- addresses an OpenJDK bug which is already fixed -->
<exclude name="AvoidInstantiatingObjectsInLoops" /> <!-- too many false positives, sometimes we need n objects -->
<exclude name="InsufficientStringBufferDeclaration" /> <!-- false positives: does not recognize if statements -->
</rule>
<rule ref="category/java/security.xml" />
</ruleset>