-
Notifications
You must be signed in to change notification settings - Fork 40
/
Copy pathpmd-ruleset.xml
76 lines (60 loc) · 3.97 KB
/
pmd-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
64
65
66
67
68
69
70
71
72
73
74
75
76
<?xml version="1.0"?>
<ruleset name="PMD HappyCoders ruleset - Hexagonal Architecture"
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 (relaxed for Hexagonal Architecture tutorial)</description>
<!-- Rule reference: https://pmd.github.io/pmd/pmd_rules_java.html -->
<rule ref="category/java/bestpractices.xml">
<exclude name="PreserveStackTrace"/> <!-- We're using very specific exceptions like "ProductNotFoundException"; for those, the stack trace is not important. -->
</rule>
<rule ref="category/java/codestyle.xml">
<exclude name="AtLeastOneConstructor"/> <!-- I don't think we should implement 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="LocalVariableCouldBeFinal"/> <!-- Using 'final' on local variables (in contrast to fields) has no effect on the compiler; IMO it's noise. -->
<exclude name="MethodArgumentCouldBeFinal"/> <!-- Using 'final' on method arguments (in contrast to fields) has no effect on the compiler; IMO it's noise. -->
<exclude name="OnlyOneReturn"/> <!-- Outdated in times of short methods. -->
</rule>
<rule ref="category/java/codestyle.xml/LongVariable">
<properties>
<property name="minimum" value="65" /> <!-- Default max is 16, which is not always enough for a descriptive name; allow longer variables. -->
</properties>
</rule>
<rule ref="category/java/codestyle.xml/ShortClassName">
<properties>
<property name="minimum" value="4" /> <!-- Default minimum is 5, that wouldn't allow a class name like "Cart". -->
</properties>
</rule>
<rule ref="category/java/codestyle.xml/ShortMethodName">
<properties>
<property name="minimum" value="2" /> <!-- Default minimum is 3, that wouldn't allow a method name like "id()". -->
</properties>
</rule>
<rule ref="category/java/codestyle.xml/ShortVariable">
<properties>
<property name="minimum" value="2" /> <!-- Default minimum is 3, that wouldn't allow a variable name like "id". -->
</properties>
</rule>
<rule ref="category/java/design.xml">
<exclude name="LawOfDemeter"/> <!-- This rule also prohibits a fluent programming style. -->
<exclude name="LoosePackageCoupling"/> <!-- This rule requires configuration. -->
</rule>
<rule ref="category/java/documentation.xml">
<exclude name="CommentRequired"/> <!-- Would require comments on all fields, public methods, and constructors. Good names are a much better documentation. -->
<exclude name="CommentSize"/> <!-- Don't limit the size of comments. -->
</rule>
<rule ref="category/java/errorprone.xml">
<exclude name="AvoidFieldNameMatchingMethodName"/><!-- I personally like using the field name also as an accessor name for final fields (like in records). -->
<exclude name="MissingSerialVersionUID"/> <!-- We're not using serialization. -->
</rule>
<rule ref="category/java/errorprone.xml/AvoidLiteralsInIfCondition">
<properties>
<property name="ignoreMagicNumbers" value="-1,0,1,2" /><!-- Allow a few other literals than the default (-1, 0). -->
</properties>
</rule>
<rule ref="category/java/multithreading.xml">
<exclude name="UseConcurrentHashMap"/> <!-- I prefer to decide on my own. -->
</rule>
<rule ref="category/java/performance.xml"/>
<rule ref="category/java/security.xml"/>
</ruleset>