summaryrefslogtreecommitdiff
path: root/tools/pmd.xml
blob: a4d73723a9c97ba3c5431cb347dca85a33aa9733 (plain)
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
<?xml version="1.0"?>

<ruleset name="ASM" 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.net/ruleset_2_0_0.xsd">
  <description>PMD rules for ASM</description>

  <rule ref="category/java/bestpractices.xml">
    <!-- Core API is using this on purpose. -->
    <exclude name="AbstractClassWithoutAbstractMethod" />
    <!-- Does not work, too many false positives. -->
    <exclude name="AccessorMethodGeneration" />
    <!-- Already covered with Checkstyle 'FinalParameters' rule. -->   
    <exclude name="AvoidReassigningParameters" />
    <!-- Used for legitimate purposes in some Writer classes. -->
    <exclude name="AvoidStringBufferField" />
    <!-- Not relevant for ASM. -->
    <exclude name="AvoidUsingHardCodedIP" />
    <exclude name="CheckResultSet" />
    <!-- Already covered with Checkstyle 'InterfaceIsType' rule. -->   
    <exclude name="ConstantsInInterface" />
    <!-- Already covered with Checkstyle 'DefaultComesLast' rule. -->   
    <exclude name="DefaultLabelNotLastInSwitchStmt" />
    <!-- Not relevant for ASM (no logging and using JUnit 5). -->
    <exclude name="GuardLogStatement" />
    <exclude name="JUnit4SuitesShouldUseSuiteAnnotation" />
    <exclude name="JUnit4TestShouldUseAfterAnnotation" />
    <exclude name="JUnit4TestShouldUseBeforeAnnotation" />
    <exclude name="JUnit4TestShouldUseTestAnnotation" />
    <!-- Would give too verbose code. -->
    <exclude name="JUnitAssertionsShouldIncludeMessage" />
    <exclude name="JUnitTestContainsTooManyAsserts" />
    <!-- Not relevant for ASM (using JUnit 5). -->
    <exclude name="JUnitUseExpected" />
    <!-- Already covered with Checkstyle 'IllegalType' rule. -->   
    <exclude name="LooseCoupling" />
    <!-- Already covered with google-java-format. -->   
    <exclude name="OneDeclarationPerLine" />
    <!-- Actually not a best practice. -->   
    <exclude name="LiteralsFirstInComparisons" />
    <!-- Already covered with Checkstyle 'MissingSwitchDefault' rule. -->   
    <exclude name="SwitchStmtsShouldHaveDefault" />
    <!-- Already covered with google-java-format. -->
    <exclude name="UnusedImports" />
    <!-- Too many false positives. -->
    <exclude name="UseVarargs" />
  </rule>
  <rule ref="category/java/bestpractices.xml/ArrayIsStoredDirectly">
    <properties>
      <property name="violationSuppressXPath"
          value="//MethodDeclaration[@Private='true' or 
              @PackagePrivate='true']" />
    </properties>
  </rule>
  <rule ref="category/java/bestpractices.xml/MethodReturnsInternalArray">
    <properties>
      <property name="violationSuppressXPath"
          value="//MethodDeclaration[@Private='true' or 
              @PackagePrivate='true']" />
    </properties>
  </rule>
  <rule ref="category/java/bestpractices.xml/ForLoopVariableCount">
    <properties>
      <property name="maximumVariables" value="2" />
    </properties>
  </rule>

  <rule ref="category/java/errorprone.xml">
    <!-- Do not want this rule. -->
    <exclude name="AssignmentInOperand" />
    <!-- Not relevant for ASM (no BigDecimal). -->
    <exclude name="AvoidDecimalLiteralsInBigDecimalConstructor" />
    <!-- Do not want these rules. -->
    <exclude name="AvoidDuplicateLiterals" />
    <exclude name="AvoidFieldNameMatchingMethodName" />
    <exclude name="AvoidLiteralsInIfCondition" />
    <!-- Not relevant for ASM (no Java Beans). -->
    <exclude name="BeanMembersShouldSerialize" />
    <!-- Too many false positives. -->
    <exclude name="CompareObjectsWithEquals" />
    <!-- Does not work, too  many false positives. -->
    <exclude name="DataflowAnomalyAnalysis" />
    <!-- Not relevant for ASM. -->
    <exclude name="DoNotHardCodeSDCard" />
    <exclude name="DontImportSun" />
    <!-- Already covered with Checkstyle 'NoFinalizer' rule. -->   
    <exclude name="FinalizeDoesNotCallSuperFinalize" />
    <exclude name="FinalizeOnlyCallsSuperFinalize" />
    <exclude name="FinalizeOverloaded" />
    <exclude name="FinalizeShouldBeProtected" />
    <!-- Not relevant for ASM (no logging and using JUnit 5). -->
    <exclude name="JUnitSpelling" />
    <exclude name="JUnitStaticSuite" />
    <exclude name="LoggerIsNotStaticFinal" />
    <exclude name="MoreThanOneLogger" />
    <!-- Needed to implement custom data structures such as linked lists. -->
    <exclude name="NullAssignment" />
    <!-- Not relevant for ASM (no logging, no dates, no EJB). -->
    <exclude name="ProperLogger" />
    <exclude name="SimpleDateFormatNeedsLocale" />
    <exclude name="StaticEJBFieldShouldBeFinal" />
    <exclude name="UseProperClassLoader" />
  </rule>
  <rule ref="category/java/errorprone.xml/ReturnEmptyCollectionRatherThanNull">
    <properties>
      <property name="violationSuppressXPath"
          value="//MethodDeclaration[@Private='true']"/>
    </properties>
  </rule>

  <rule ref="category/java/performance.xml">
    <!-- Too many false positives. -->
    <exclude name="AvoidInstantiatingObjectsInLoops" />
    <!-- Shorts can be decrease memory use, without decreasing performance. -->
    <exclude name="AvoidUsingShortType" />
    <!-- Not relevant for ASM (no BigInteger). -->
    <exclude name="BigIntegerInstantiation" />
    <!-- Does not work, too many false positives. -->
    <exclude name="InsufficientStringBufferDeclaration" />
  </rule>
</ruleset>