1<?xml version="1.0"?> 2 3<ruleset name="ASM" xmlns="http://pmd.sourceforge.net/ruleset/2.0.0" 4 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 5 xsi:schemaLocation="http://pmd.sourceforge.net/ruleset/2.0.0 6 https://pmd.sourceforge.net/ruleset_2_0_0.xsd"> 7 <description>PMD rules for ASM</description> 8 9 <rule ref="category/java/bestpractices.xml"> 10 <!-- Core API is using this on purpose. --> 11 <exclude name="AbstractClassWithoutAbstractMethod" /> 12 <!-- Does not work, too many false positives. --> 13 <exclude name="AccessorMethodGeneration" /> 14 <!-- Already covered with Checkstyle 'FinalParameters' rule. --> 15 <exclude name="AvoidReassigningParameters" /> 16 <!-- Used for legitimate purposes in some Writer classes. --> 17 <exclude name="AvoidStringBufferField" /> 18 <!-- Not relevant for ASM. --> 19 <exclude name="AvoidUsingHardCodedIP" /> 20 <exclude name="CheckResultSet" /> 21 <!-- Already covered with Checkstyle 'InterfaceIsType' rule. --> 22 <exclude name="ConstantsInInterface" /> 23 <!-- Already covered with Checkstyle 'DefaultComesLast' rule. --> 24 <exclude name="DefaultLabelNotLastInSwitchStmt" /> 25 <!-- Not relevant for ASM (no logging and using JUnit 5). --> 26 <exclude name="GuardLogStatement" /> 27 <exclude name="JUnit4SuitesShouldUseSuiteAnnotation" /> 28 <exclude name="JUnit4TestShouldUseAfterAnnotation" /> 29 <exclude name="JUnit4TestShouldUseBeforeAnnotation" /> 30 <exclude name="JUnit4TestShouldUseTestAnnotation" /> 31 <!-- Would give too verbose code. --> 32 <exclude name="JUnitAssertionsShouldIncludeMessage" /> 33 <exclude name="JUnitTestContainsTooManyAsserts" /> 34 <!-- Not relevant for ASM (using JUnit 5). --> 35 <exclude name="JUnitUseExpected" /> 36 <!-- Already covered with Checkstyle 'IllegalType' rule. --> 37 <exclude name="LooseCoupling" /> 38 <!-- Already covered with google-java-format. --> 39 <exclude name="OneDeclarationPerLine" /> 40 <!-- Actually not a best practice. --> 41 <exclude name="LiteralsFirstInComparisons" /> 42 <!-- Already covered with Checkstyle 'MissingSwitchDefault' rule. --> 43 <exclude name="SwitchStmtsShouldHaveDefault" /> 44 <!-- Already covered with google-java-format. --> 45 <exclude name="UnusedImports" /> 46 <!-- Too many false positives. --> 47 <exclude name="UseVarargs" /> 48 </rule> 49 <rule ref="category/java/bestpractices.xml/ArrayIsStoredDirectly"> 50 <properties> 51 <property name="violationSuppressXPath" 52 value="//MethodDeclaration[@Private='true' or 53 @PackagePrivate='true']" /> 54 </properties> 55 </rule> 56 <rule ref="category/java/bestpractices.xml/MethodReturnsInternalArray"> 57 <properties> 58 <property name="violationSuppressXPath" 59 value="//MethodDeclaration[@Private='true' or 60 @PackagePrivate='true']" /> 61 </properties> 62 </rule> 63 <rule ref="category/java/bestpractices.xml/ForLoopVariableCount"> 64 <properties> 65 <property name="maximumVariables" value="2" /> 66 </properties> 67 </rule> 68 69 <rule ref="category/java/errorprone.xml"> 70 <!-- Do not want this rule. --> 71 <exclude name="AssignmentInOperand" /> 72 <!-- Not relevant for ASM (no BigDecimal). --> 73 <exclude name="AvoidDecimalLiteralsInBigDecimalConstructor" /> 74 <!-- Do not want these rules. --> 75 <exclude name="AvoidDuplicateLiterals" /> 76 <exclude name="AvoidFieldNameMatchingMethodName" /> 77 <exclude name="AvoidLiteralsInIfCondition" /> 78 <!-- Not relevant for ASM (no Java Beans). --> 79 <exclude name="BeanMembersShouldSerialize" /> 80 <!-- Too many false positives. --> 81 <exclude name="CompareObjectsWithEquals" /> 82 <!-- Does not work, too many false positives. --> 83 <exclude name="DataflowAnomalyAnalysis" /> 84 <!-- Not relevant for ASM. --> 85 <exclude name="DoNotHardCodeSDCard" /> 86 <exclude name="DontImportSun" /> 87 <!-- Already covered with Checkstyle 'NoFinalizer' rule. --> 88 <exclude name="FinalizeDoesNotCallSuperFinalize" /> 89 <exclude name="FinalizeOnlyCallsSuperFinalize" /> 90 <exclude name="FinalizeOverloaded" /> 91 <exclude name="FinalizeShouldBeProtected" /> 92 <!-- Not relevant for ASM (no logging and using JUnit 5). --> 93 <exclude name="JUnitSpelling" /> 94 <exclude name="JUnitStaticSuite" /> 95 <exclude name="LoggerIsNotStaticFinal" /> 96 <exclude name="MoreThanOneLogger" /> 97 <!-- Needed to implement custom data structures such as linked lists. --> 98 <exclude name="NullAssignment" /> 99 <!-- Not relevant for ASM (no logging, no dates, no EJB). --> 100 <exclude name="ProperLogger" /> 101 <exclude name="SimpleDateFormatNeedsLocale" /> 102 <exclude name="StaticEJBFieldShouldBeFinal" /> 103 <exclude name="UseProperClassLoader" /> 104 </rule> 105 <rule ref="category/java/errorprone.xml/ReturnEmptyCollectionRatherThanNull"> 106 <properties> 107 <property name="violationSuppressXPath" 108 value="//MethodDeclaration[@Private='true']"/> 109 </properties> 110 </rule> 111 112 <rule ref="category/java/performance.xml"> 113 <!-- Too many false positives. --> 114 <exclude name="AvoidInstantiatingObjectsInLoops" /> 115 <!-- Shorts can be decrease memory use, without decreasing performance. --> 116 <exclude name="AvoidUsingShortType" /> 117 <!-- Not relevant for ASM (no BigInteger). --> 118 <exclude name="BigIntegerInstantiation" /> 119 <!-- Does not work, too many false positives. --> 120 <exclude name="InsufficientStringBufferDeclaration" /> 121 </rule> 122</ruleset> 123 124