-
Notifications
You must be signed in to change notification settings - Fork 2
/
pmd-ruleset.xml
93 lines (89 loc) · 3.8 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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
<?xml version="1.0"?>
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="Android Application Rules"
xmlns="http://pmd.sf.net/ruleset/1.0.0"
xsi:noNamespaceSchemaLocation="http://pmd.sf.net/ruleset_xml_schema.xsd"
xsi:schemaLocation="http://pmd.sf.net/ruleset/1.0.0 http://pmd.sf.net/ruleset_xml_schema.xsd">
<!--Reference: https://pmd.github.io/pmd-5.8.0/pmd-java/rules/index.html-->
<description>Custom rule set for Android application</description>
<exclude-pattern>.*/R.java</exclude-pattern>
<exclude-pattern>.*/gen/.*</exclude-pattern>
<rule ref="category/java/bestpractices.xml">
<!-- Include if you care more about performance and method counts than encapsulation. -->
<exclude name="AccessorMethodGeneration"/>
</rule>
<rule ref="category/java/bestpractices.xml/JUnitTestContainsTooManyAsserts">
<properties>
<property name="maximumAsserts" value="3"/>
</properties>
</rule>
<rule ref="category/java/codestyle.xml">
<exclude name="AtLeastOneConstructor"/>
<exclude name="AbstractNaming"/>
<!-- Overkill -->
<exclude name="AvoidFinalLocalVariable"/>
<exclude name="CallSuperInConstructor"/>
<exclude name="LongVariable"/>
<exclude name="ShortMethodName"/>
<exclude name="ShortVariable"/>
<exclude name="ShortClassName"/>
<exclude name="GenericsNaming"/>
<exclude name="DefaultPackage"/>
<exclude name="OnlyOneReturn"/>
<!-- Exclude if underscore is allowed in variable names. -->
<!--<exclude name="VariableNamingConventions" />-->
<!-- Exclude if you use Espresso. -->
<exclude name="TooManyStaticImports"/>
<!-- Exclude if you use a lot of package private declarations. -->
<!--<exclude name="CommentDefaultAccessModifier"/>-->
</rule>
<rule ref="category/java/codestyle.xml/ClassNamingConventions">
<properties>
<!-- Allow utility class to have normal names. -->
<property name="utilityClassPattern" value="[A-Z][a-zA-Z]+"/>
</properties>
</rule>
<rule ref="category/java/design.xml">
<!-- Very common in activities. -->
<exclude name="LawOfDemeter"/>
<exclude name="LoosePackageCoupling"/>
</rule>
<rule ref="category/java/design.xml/NcssCount">
<properties>
<property name="methodReportLevel" value="20"/>
</properties>
</rule>
<rule ref="category/java/documentation.xml">
<!-- The copyright header is too large so just ignore this rule. -->
<exclude name="CommentSize"/>
</rule>
<!--<rule ref="category/java/documentation.xml/CommentSize">-->
<!--<properties>-->
<!--<property name="maxLines" value="7"/>-->
<!--<property name="maxLineLength" value="120"/>-->
<!--</properties>-->
<!--</rule>-->
<rule ref="category/java/errorprone.xml">
<!-- Only classes implements Serializable should care about this rule. -->
<exclude name="BeanMembersShouldSerialize"/>
<!-- This rule always reports error for for-each loop. -->
<exclude name="DataflowAnomalyAnalysis"/>
<!-- Usually intended -->
<exclude name="NullAssignment"/>
<!-- Exclude if causes problems with SQL Strings that usually require duplication -->
<!--<exclude name="AvoidDuplicateLiterals"/>-->
</rule>
<!-- Allow field like isXXX has the same name as a method. -->
<rule ref="category/java/errorprone.xml/AvoidFieldNameMatchingMethodName">
<properties>
<property name="violationSuppressRegex" value="Field is[A-Z][\w]* has the same name as a method"/>
</properties>
</rule>
<!-- Add "1" to the list of default allowed magic numbers [-1,0]. -->
<rule ref="category/java/errorprone.xml/AvoidLiteralsInIfCondition">
<properties>
<property name="ignoreMagicNumbers" value="-1,0,1"/>
</properties>
</rule>
<rule ref="category/java/multithreading.xml"/>
<rule ref="category/java/performance.xml"/>
</ruleset>