-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathpmd-rules.xml
119 lines (108 loc) · 5.16 KB
/
pmd-rules.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
<?xml version="1.0"?>
<ruleset name="mbed ruleset" 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-rules</description>
<rule ref="category/java/design.xml">
<!-- See the explanation for TooManyMethods.-->
<exclude name="TooManyFields" />
<!-- Design is very hard to measure by numbers like this.-->
<!-- The number and quality of dependencies might be a better indicator, -->
<!-- and that requires a different tool.-->
<exclude name="TooManyMethods" />
<!-- See the explanation for TooManyMethods.-->
<exclude name="ExcessivePublicCount" />
<!-- Needs better understanding and proper configuration-->
<exclude name="CyclomaticComplexity" />
<!-- It's just extra effort to write and read the final keyword-->
<exclude name="ClassWithOnlyPrivateConstructorsShouldBeFinal"/>
<exclude name="AvoidCatchingGenericException"/>
<exclude name="GodClass"/>
<exclude name="ExcessiveImports"/>
<exclude name="TooManyFields"/>
<exclude name="AvoidThrowingRawExceptionTypes"/>
<exclude name="DataClass"/>
<exclude name="UseUtilityClass"/>
<exclude name="LawOfDemeter"/>
<exclude name="CognitiveComplexity"/>
<exclude name="AvoidUncheckedExceptionsInSignatures"/>
<exclude name="LoosePackageCoupling"/>
</rule>
<rule ref="category/java/design.xml/NPathComplexity">
<properties>
<!-- ignore this run on methods: equals and hashCode-->
<property name="violationSuppressXPath"
value="./ancestor::ClassOrInterfaceBodyDeclaration/MethodDeclaration[@Name='equals' or @Name='hashCode']"/>
</properties>
</rule>
<rule ref="category/java/design.xml/SimplifyBooleanReturns">
<properties>
<!-- ignore this run on methods: equals-->
<property name="violationSuppressXPath"
value="./ancestor::ClassOrInterfaceBodyDeclaration/MethodDeclaration[@Name='equals']"/>
</properties>
</rule>
<rule ref="category/java/bestpractices.xml">
<exclude name="GuardLogStatement"/>
<exclude name="MethodReturnsInternalArray"/>
<exclude name="ArrayIsStoredDirectly"/>
<!-- There are valid reasons for passing arrays (making it nullable for example)-->
<exclude name="UseVarargs"/>
<exclude name="PreserveStackTrace"/>
</rule>
<rule ref="category/java/errorprone.xml">
<exclude name="MissingSerialVersionUID"/>
<exclude name="AvoidLiteralsInIfCondition"/>
<!-- Opinion, for me a getter is not a command, it's a declarative-->
<!-- data reference-->
<exclude name="AvoidFieldNameMatchingMethodName"/>
<exclude name="UseLocaleWithCaseConversions"/>
<exclude name="NullAssignment"/>
<exclude name="EmptyCatchBlock"/>
<exclude name="CloseResource"/>
<exclude name="ReturnEmptyCollectionRatherThanNull"/>
</rule>
<rule ref="category/java/errorprone.xml/CompareObjectsWithEquals">
<properties>
<!-- ignore this run on methods: equals-->
<property name="violationSuppressXPath"
value="./ancestor::ClassOrInterfaceBodyDeclaration/MethodDeclaration[@Name='equals']"/>
</properties>
</rule>
<rule ref="category/java/codestyle.xml">
<!-- Why should generics not be named properly, like all other things-->
<!-- (well, except Windows filesystem roots)?-->
<exclude name="GenericsNaming"/>
<!-- It can be long if it's the only way to make it good-->
<exclude name="LongVariable"/>
<!-- It can be short if it's good-->
<exclude name="ShortVariable"/>
<!-- It can be short if it's good-->
<exclude name="ShortClassName"/>
<!-- It can be short if it's good-->
<exclude name="ShortMethodName"/>
<!-- Good principle but too verbose in practice: -->
<exclude name="MethodArgumentCouldBeFinal"/>
<!-- Good principle and maybe sometimes even practical but not in this
project: -->
<exclude name="LocalVariableCouldBeFinal"/>
<exclude name="OnlyOneReturn"/>
<exclude name="AtLeastOneConstructor"/>
<exclude name="CallSuperInConstructor"/>
<exclude name="CommentDefaultAccessModifier"/>
<exclude name="FormalParameterNamingConventions"/>
<exclude name="ConfusingTernary"/>
<exclude name="UseUnderscoresInNumericLiterals"/>
<exclude name="TooManyStaticImports"/>
<exclude name="FieldNamingConventions"/>
</rule>
<rule ref="category/java/multithreading.xml">
<exclude name="DoNotUseThreads"/>
<exclude name="UseConcurrentHashMap"/>
<exclude name="AvoidUsingVolatile"/>
</rule>
<rule ref="category/java/performance.xml">
<exclude name="AvoidFileStream"/>
<exclude name="AvoidInstantiatingObjectsInLoops"/>
</rule>
</ruleset>