|
| 1 | +<?xml version="1.0" encoding="UTF-8"?> |
| 2 | + |
| 3 | +<!-- |
| 4 | +Copyright 2018 the original author or authors. |
| 5 | +
|
| 6 | +Licensed under the Apache License, Version 2.0 (the "License"); |
| 7 | +you may not use this file except in compliance with the License. |
| 8 | +You may obtain a copy of the License at |
| 9 | +
|
| 10 | + http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | +
|
| 12 | +Unless required by applicable law or agreed to in writing, software |
| 13 | +distributed under the License is distributed on an "AS IS" BASIS, |
| 14 | +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 | +See the License for the specific language governing permissions and |
| 16 | +limitations under the License. |
| 17 | +--> |
| 18 | + |
| 19 | +<ruleset name="Apulse PMD rule set" |
| 20 | + xmlns="http://pmd.sourceforge.net/ruleset/2.0.0" |
| 21 | + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
| 22 | + xsi:schemaLocation="http://pmd.sourceforge.net/ruleset/2.0.0 http://pmd.sourceforge.net/ruleset_2_0_0.xsd"> |
| 23 | + |
| 24 | + <description>PMD Rules</description> |
| 25 | + |
| 26 | + <rule ref="rulesets/java/basic.xml"> |
| 27 | + <exclude name="AvoidUsingHardCodedIP" /> |
| 28 | + </rule> |
| 29 | + |
| 30 | + <rule ref="rulesets/java/braces.xml" /> |
| 31 | + <rule ref="rulesets/java/clone.xml" /> |
| 32 | + <rule ref="rulesets/java/unusedcode.xml"/> |
| 33 | + <rule ref="rulesets/java/finalizers.xml" /> |
| 34 | + |
| 35 | + |
| 36 | + <rule ref="rulesets/java/imports.xml"> |
| 37 | + <!-- Stupid rule... --> |
| 38 | + <exclude name="TooManyStaticImports" /> |
| 39 | + </rule> |
| 40 | + |
| 41 | + <rule ref="rulesets/java/codesize.xml" > |
| 42 | + <!-- See the explanation for TooManyMethods.--> |
| 43 | + <exclude name="TooManyFields" /> |
| 44 | + <!-- Design is very hard to measure by numbers like this.--> |
| 45 | + <!-- The number and quality of dependencies might be a better indicator, --> |
| 46 | + <!-- and that requires a different tool.--> |
| 47 | + <exclude name="TooManyMethods" /> |
| 48 | + <!-- See the explanation for TooManyMethods.--> |
| 49 | + <exclude name="ExcessivePublicCount" /> |
| 50 | + <!-- Needs better understanding and proper configuration--> |
| 51 | + <exclude name="StdCyclomaticComplexity" /> |
| 52 | + <!-- Needs better understanding and proper configuration--> |
| 53 | + <exclude name="ModifiedCyclomaticComplexity" /> |
| 54 | + <!-- See the explanation for TooManyMethods.--> |
| 55 | + <exclude name="ExcessiveParameterList" /> |
| 56 | + <!-- Too abstract rule --> |
| 57 | + <exclude name="CyclomaticComplexity" /> |
| 58 | + </rule> |
| 59 | + |
| 60 | + <rule ref="rulesets/java/design.xml"> |
| 61 | + <!-- Sometimes important to avoid "DOS attack" but not as a general rule--> |
| 62 | + <exclude name="AvoidSynchronizedAtMethodLevel" /> |
| 63 | + <!-- It's just extra effort to write and read the final keyword--> |
| 64 | + <exclude name="ClassWithOnlyPrivateConstructorsShouldBeFinal" /> |
| 65 | + <!-- Maybe good idea if PMD could exclude null checks from this--> |
| 66 | + <exclude name="ConfusingTernary" /> |
| 67 | + <!-- Statistical analysis is prone to givin false positives. Potential god classes--> |
| 68 | + <!-- most probably violate something else, too.--> |
| 69 | + <!-- And dependency analysis tools also help here.--> |
| 70 | + <exclude name="GodClass" /> |
| 71 | + <!-- Switch is sometimes very readable--> |
| 72 | + <exclude name="TooFewBranchesForASwitchStatement"/> |
| 73 | + <!-- A static utility is a static utility even if it masquerades as something--> |
| 74 | + <!-- else by using the Singleton pattern--> |
| 75 | + <exclude name="UseUtilityClass" /> |
| 76 | + <!-- This is good advice, but since it's violated so much in this project--> |
| 77 | + <!-- and the problem is not big (especially with good syntax colouring),--> |
| 78 | + <!-- we'll keep this ignored for now.--> |
| 79 | + <exclude name="AvoidReassigningParameters" /> |
| 80 | + <!-- Good idea almost always, but not quite.--> |
| 81 | + <!--<exclude name="ReturnEmptyArrayRatherThanNull" />--> |
| 82 | + <!-- Sometimes one step at a time makes clearer code.--> |
| 83 | + <!-- Debugging is also easier if the return value is in a variable.--> |
| 84 | + <exclude name="UnnecessaryLocalBeforeReturn" /> |
| 85 | + <!-- There are valid reasons for passing arrays (making it nullable for example)--> |
| 86 | + <exclude name="UseVarargs" /> |
| 87 | + <!-- TODO explain what false positives this gives--> |
| 88 | + <exclude name="MissingBreakInSwitch" /> |
| 89 | + <!-- TODO enable when all findings have been fixed--> |
| 90 | + <exclude name="UseLocaleWithCaseConversions" /> |
| 91 | + <!-- It gives a lot of warnings on 'equals' method, fixing would decrease readability--> |
| 92 | + <exclude name="SimplifyBooleanReturns"/> |
| 93 | + <!--Gives false positive--> |
| 94 | + <exclude name="FieldDeclarationsShouldBeAtStartOfClass"/> |
| 95 | + <!-- Good rule but in practice to often suppressed --> |
| 96 | + <exclude name="PreserveStackTrace"/> |
| 97 | + |
| 98 | + <exclude name="AccessorMethodGeneration"/> |
| 99 | + </rule> |
| 100 | + |
| 101 | + <rule ref="rulesets/java/migrating.xml"> |
| 102 | + <!-- The annotation is not as readable and there is no way to state which--> |
| 103 | + <!-- line should throw the exception and with what message--> |
| 104 | + <exclude name="JUnitUseExpected" /> |
| 105 | + <!-- Main code is not junit code--> |
| 106 | + <exclude name="JUnit4TestShouldUseTestAnnotation" /> |
| 107 | + </rule> |
| 108 | + |
| 109 | + <rule ref="rulesets/java/naming.xml"> |
| 110 | + <!-- Often good to start name with Abstract, but on the other hand this--> |
| 111 | + <!-- rule is a bit too much like Hungarian notation and I in interface names.--> |
| 112 | + <!-- Who cares if it's abstract or not when you are using it?--> |
| 113 | + <exclude name="AbstractNaming" /> |
| 114 | + <!-- Opinion, for me a getter is not a command, it's a declarative--> |
| 115 | + <!-- data reference--> |
| 116 | + <exclude name="AvoidFieldNameMatchingMethodName" /> |
| 117 | + <!-- Why should generics not be named properly, like all other things--> |
| 118 | + <!-- (well, except Windows filesystem roots)?--> |
| 119 | + <exclude name="GenericsNaming" /> |
| 120 | + <!-- It can be long if it's the only way to make it good--> |
| 121 | + <exclude name="LongVariable" /> |
| 122 | + <!-- It can be short if it's good--> |
| 123 | + <exclude name="ShortVariable" /> |
| 124 | + <!-- TODO explain why.--> |
| 125 | + <exclude name="BooleanGetMethodName" /> |
| 126 | + <!-- It can be short if it's good--> |
| 127 | + <exclude name="ShortClassName" /> |
| 128 | + <!-- It can be short if it's good--> |
| 129 | + <exclude name="ShortMethodName" /> |
| 130 | + </rule> |
| 131 | + |
| 132 | + <rule ref="rulesets/java/optimizations.xml"> |
| 133 | + <!-- Too many false hits. Optimization can't be done with static analysis. |
| 134 | + Besides, following this may encourage the antipattern of using too broad |
| 135 | + scope for stuff: --> |
| 136 | + <exclude name="AvoidInstantiatingObjectsInLoops" /> |
| 137 | + <!-- Good principle but too verbose in practice: --> |
| 138 | + <exclude name="MethodArgumentCouldBeFinal" /> |
| 139 | + <!-- Good principle and maybe sometimes even practical but not in this |
| 140 | + project: --> |
| 141 | + <exclude name="LocalVariableCouldBeFinal" /> |
| 142 | + <exclude name="RedundantFieldInitializer" /> |
| 143 | + </rule> |
| 144 | + |
| 145 | + <rule ref="rulesets/java/strictexception.xml" > |
| 146 | + <!-- NPE communicates very cleary what is happening, it is not--> |
| 147 | + <!-- interesting who reports it (jvm or user code)--> |
| 148 | + <exclude name="AvoidThrowingNullPointerException" /> |
| 149 | + <!-- TODO explain why--> |
| 150 | + <exclude name="AvoidCatchingGenericException" /> |
| 151 | + <!-- TODO explain why--> |
| 152 | + <exclude name="AvoidThrowingRawExceptionTypes" /> |
| 153 | + <!-- One valid case is to catch runtime, throw as such and after that--> |
| 154 | + <!-- catch Exception and wrap as runtime.--> |
| 155 | + <!-- Without the first all runtimes are unnecessarily wrapped.--> |
| 156 | + <exclude name="AvoidRethrowingException" /> |
| 157 | + <!-- There are case which should throws generic exceptions --> |
| 158 | + <exclude name="SignatureDeclareThrowsException" /> |
| 159 | + </rule> |
| 160 | + |
| 161 | + <rule ref="rulesets/java/strings.xml" > |
| 162 | + <!-- Splitting to multiple lines is sometimes more readable.--> |
| 163 | + <!-- Besides, where's the proof that it affects performance?--> |
| 164 | + <exclude name="ConsecutiveAppendsShouldReuse" /> |
| 165 | + </rule> |
| 166 | +</ruleset> |
0 commit comments