@@ -23,144 +23,59 @@ limitations under the License.
2323
2424 <description >PMD Rules</description >
2525
26- <rule ref =" rulesets /java/basic .xml" >
26+ <rule ref =" category /java/bestpractices .xml" >
2727 <exclude name =" AvoidUsingHardCodedIP" />
28+ <exclude name =" UseVarargs" />
2829 </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... -->
30+ <rule ref =" category/java/codestyle.xml" >
31+ <exclude name =" AbstractNaming" />
32+ <exclude name =" AtLeastOneConstructor" />
33+ <exclude name =" AvoidPrefixingMethodParameters" />
34+ <exclude name =" CommentDefaultAccessModifier" />
35+ <exclude name =" DefaultPackage" />
36+ <exclude name =" FieldDeclarationsShouldBeAtStartOfClass" />
37+ <exclude name =" LocalVariableCouldBeFinal" />
38+ <exclude name =" LongVariable" />
39+ <exclude name =" MethodArgumentCouldBeFinal" />
40+ <exclude name =" OnlyOneReturn" />
41+ <exclude name =" ShortClassName" />
42+ <exclude name =" ShortMethodName" />
43+ <exclude name =" ShortVariable" />
3844 <exclude name =" TooManyStaticImports" />
45+ <exclude name =" UselessParentheses" />
3946 </rule >
40-
41- <rule ref =" rulesets/java/codesize.xml" >
42- <!-- See the explanation for TooManyMethods.-->
47+ <rule ref =" category/java/design.xml" >
48+ <exclude name =" AvoidCatchingGenericException" />
49+ <exclude name =" AvoidRethrowingException" />
50+ <exclude name =" AvoidThrowingNullPointerException" />
51+ <exclude name =" DataClass" />
52+ <exclude name =" ExcessiveImports" />
53+ <exclude name =" ExcessivePublicCount" />
54+ <exclude name =" LawOfDemeter" />
55+ <exclude name =" LoosePackageCoupling" />
4356 <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.-->
4757 <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 >
5958
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" />
59+ <!-- remove it -->
60+ <exclude name =" NcssCount" />
9961 </rule >
62+ <rule ref =" category/java/documentation.xml" >
63+ <exclude name =" CommentSize" />
10064
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" />
65+ <!-- remove it -->
66+ <exclude name =" CommentRequired" />
10767 </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-->
68+ <rule ref =" category/java/errorprone.xml" >
11669 <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" />
70+ <exclude name =" AvoidFieldNameMatchingTypeName" />
71+ <exclude name =" BeanMembersShouldSerialize" />
72+ <exclude name =" DataflowAnomalyAnalysis" />
73+ <exclude name =" DoNotCallSystemExit" />
74+ <exclude name =" MissingBreakInSwitch" />
14375 </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" />
76+ <rule ref =" category/java/multithreading.xml" >
15977 </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" />
78+ <rule ref =" category/java/performance.xml" >
79+ <exclude name =" AvoidUsingShortType" />
16580 </rule >
16681</ruleset >
0 commit comments