-
Notifications
You must be signed in to change notification settings - Fork 23
/
ruleset.xml
63 lines (52 loc) · 3.18 KB
/
ruleset.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
<?xml version="1.0"?>
<ruleset name="PMD HappyCoders Rules (relaxed for binary tree repository)"
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 HappyCoders.eu</description>
<rule ref="category/java/bestpractices.xml">
<exclude name="AvoidReassigningParameters"/> <!-- In Java, this is OK, IMO -->
<exclude name="SwitchStmtsShouldHaveDefault"/><!-- PMD doesn't recognize Java's new switch statements -->
</rule>
<rule ref="category/java/codestyle.xml">
<exclude name="AtLeastOneConstructor"/> <!-- No need for artificial default constructors -->
<exclude name="CommentDefaultAccessModifier"/><!-- We don't comment why we make fields private, protected or public. So why should we comment on default access? -->
<exclude name="ConfusingTernary"/> <!-- Sometimes they make the code flow easier to follow -->
<exclude name="LocalVariableCouldBeFinal"/> <!-- Personal taste -->
<exclude name="MethodArgumentCouldBeFinal"/> <!-- Personal taste -->
<exclude name="OnlyOneReturn"/> <!-- Makes methods more complicated than necessary, IMO -->
<exclude name="ShortClassName"/> <!-- Wouldn't allow class names like "User" -->
<exclude name="ShortMethodName"/> <!-- Wouldn't allow method names like "of" -->
</rule>
<rule ref="category/java/codestyle.xml/ClassNamingConventions">
<properties>
<property name="utilityClassPattern" value="[A-Z][a-zA-Z0-9]*" /><!-- Don't enforce specific names on utility classes! -->
</properties>
</rule>
<rule ref="category/java/codestyle.xml/LongVariable">
<properties>
<property name="minimum" value="33" /> <!-- Default max is 16, which is not always enough -->
</properties>
</rule>
<rule ref="category/java/design.xml">
<exclude name="GodClass"/> <!-- "God classes do too many things, are very big and overly complex" - we accept that for the Red-Black Tree -->
<exclude name="TooManyMethods"/> <!-- We also accept this for the Red-Black Tree -->
</rule>
<rule ref="category/java/documentation.xml">
<exclude name="CommentRequired"/> <!-- Don't need comments on *all* fields -->
<exclude name="CommentSize"/> <!-- Don't limit the size of comments -->
</rule>
<rule ref="category/java/errorprone.xml">
<exclude name="BeanMembersShouldSerialize"/><!-- We don't want to serialize anything -->
<exclude name="CompareObjectsWithEquals"/> <!-- We use == to compare node instances -->
<exclude name="NullAssignment"/> <!-- We don't want all references (in Node, for example) be an Optional! -->
</rule>
<rule ref="category/java/errorprone.xml/AvoidLiteralsInIfCondition">
<properties>
<property name="ignoreMagicNumbers" value="-1,0,1" /><!-- Default is only -1 and 0; add 1 -->
</properties>
</rule>
<rule ref="category/java/multithreading.xml"/>
<rule ref="category/java/performance.xml"/>
<rule ref="category/java/security.xml"/>
</ruleset>