source: josm/trunk/tools/pmd/josm-ruleset.xml

Last change on this file was 19113, checked in by taylor.smock, 5 weeks ago

Update PMD to 7.2.0

A bunch of rules were deprecated and replaced and the XPath expressions had to be updated from XPath 1 to XPath 3.

File size: 10.3 KB
Line 
1<?xml version="1.0"?>
2<ruleset name="JOSM ruleset"
3 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 https://pmd.sourceforge.io/ruleset_2_0_0.xsd">
6
7 <description>JOSM PMD ruleset</description>
8 <!-- Generated files -->
9 <exclude-pattern>.*/org/openstreetmap/josm/gui/mappaint/mapcss/parsergen/.*</exclude-pattern>
10
11 <rule ref="category/java/bestpractices.xml">
12 <exclude name="ArrayIsStoredDirectly"/>
13 <exclude name="AvoidPrintStackTrace"/>
14 <exclude name="AvoidReassigningLoopVariables"/>
15 <exclude name="AvoidReassigningParameters"/>
16 <exclude name="AvoidStringBufferField"/>
17 <exclude name="ConstantsInInterface"/>
18 <exclude name="GuardLogStatement"/>
19 <exclude name="JUnit4TestShouldUseTestAnnotation" reason="False positive in src/org/openstreetmap/josm/data/validation/Test.java"/>
20 <exclude name="LiteralsFirstInComparisons" reason="Introduced in 6.24, some positives in source code at this time. Replaces PositionLiteralsFirstInComparisons."/>
21 <exclude name="LooseCoupling"/>
22 <exclude name="MethodReturnsInternalArray"/>
23 <exclude name="OneDeclarationPerLine"/>
24 <exclude name="ReplaceHashtableWithMap"/>
25 <exclude name="SwitchStmtsShouldHaveDefault"/>
26 <exclude name="SystemPrintln"/>
27 <exclude name="UnusedAssignment" reason="Introduced in 6.26, some number of positives in source code at this time"/>
28 <exclude name="UnusedPrivateMethod" reason="Broken since PMD 6.33, see https://github.com/pmd/pmd/issues/3468"/>
29 <exclude name="UnusedPrivateField" reason="Broken in 7.2.x"/>
30 <exclude name="UseVarargs"/>
31 </rule>
32 <rule ref="category/java/bestpractices.xml/ForLoopCanBeForeach">
33 <properties>
34 <!-- The list is expanded during iteration -->
35 <property name="violationSuppressXPath" value="//ClassDeclaration[@SimpleName='PurgeCommand']/ClassBody/MethodDeclaration[@Name='build']/Block/IfStatement/Block/ForStatement/InfixExpression/MethodCall/VariableAccess[@Name='relLst']"/>
36 </properties>
37 </rule>
38 <rule ref="category/java/bestpractices.xml/AvoidUsingHardCodedIP">
39 <properties>
40 <property name="violationSuppressXPath" value="//ClassDeclaration[@SimpleName='DefaultProxySelector' or @SimpleName='RemoteControl']"/>
41 </properties>
42 </rule>
43 <rule ref="category/java/codestyle.xml">
44 <exclude name="AtLeastOneConstructor"/>
45 <exclude name="BooleanGetMethodName"/>
46 <exclude name="CallSuperInConstructor"/>
47 <exclude name="ClassNamingConventions"/>
48 <exclude name="CommentDefaultAccessModifier"/>
49 <exclude name="ConfusingTernary"/>
50 <exclude name="ControlStatementBraces"/>
51 <!-- EmptyControlStatement is not configurable, so the behavior of the old excludes of EmptyIfStmt/EmptyWhileStmt (errorprone.xml) while getting new functionality cannot be done -->
52 <exclude name="EmptyControlStatement"/>
53 <exclude name="EmptyMethodInAbstractClassShouldBeAbstract"/>
54 <exclude name="FieldDeclarationsShouldBeAtStartOfClass"/>
55 <exclude name="FieldNamingConventions"/>
56 <exclude name="LinguisticNaming"/>
57 <exclude name="LocalVariableCouldBeFinal"/>
58 <exclude name="LongVariable"/>
59 <exclude name="MethodArgumentCouldBeFinal"/>
60 <exclude name="MethodNamingConventions"/>
61 <exclude name="NoPackage"/>
62 <exclude name="OnlyOneReturn"/>
63 <exclude name="PrematureDeclaration"/>
64 <exclude name="ShortClassName"/>
65 <exclude name="ShortMethodName"/>
66 <exclude name="ShortVariable"/>
67 <exclude name="TooManyStaticImports"/>
68 <exclude name="UnnecessaryCast" reason="Introduced in 6.24, some positives in source code at this time"/>
69 <exclude name="UnnecessaryConstructor"/>
70 <exclude name="UseUnderscoresInNumericLiterals"/>
71 <exclude name="UselessParentheses"/>
72 <exclude name="UnnecessaryFullyQualifiedName" reason="7.x increased sensitivity (250 new issues), and it now warns on qualified names inside a class, e.g. ClassName.STATIC_VARIABLE. Should probably be fixed in our source code."/>
73 </rule>
74 <rule ref="category/java/codestyle.xml/ShortMethodName">
75 <properties>
76 <property name="violationSuppressXPath" value="//MethodDeclaration[@Name='at' or @Name='ht' or @Name='of' or @Name='ok' or @Name='tr']"/>
77 </properties>
78 </rule>
79 <rule ref="category/java/codestyle.xml/MethodNamingConventions">
80 <properties>
81 <property name="violationSuppressXPath" value="//ClassDeclaration[@SimpleName='Functions' or @SimpleName='PseudoClasses' or @SimpleName='Role' or @SimpleName='TaggingPreset' or @SimpleName='RegionSpecific']"/>
82 </properties>
83 </rule>
84 <rule ref="category/java/codestyle.xml/FieldNamingConventions">
85 <properties>
86 <property name="enumConstantPattern" value="[A-Za-z][A-Za-z_0-9]*"/>
87 <property name="violationSuppressXPath" value="//FieldDeclaration[@Visibility='public']
88 | //FieldDeclaration/ModifierList/Annotation[@SimpleName='StructEntry']
89 | //FieldDeclaration/ClassType[@SimpleName!='Boolean' and
90 @SimpleName!='Byte' and
91 @SimpleName!='Character' and
92 @SimpleName!='Class' and
93 @SimpleName!='Double' and
94 @SimpleName!='Enum' and
95 @SimpleName!='Float' and
96 @SimpleName!='Integer' and
97 @SimpleName!='Long' and
98 @SimpleName!='Number' and
99 @SimpleName!='Short' and
100 @SimpleName!='String' ]"/>
101 </properties>
102 </rule>
103 <rule ref="category/java/codestyle.xml/LongVariable">
104 <properties>
105 <property name="minimum" value="44"/>
106 </properties>
107 </rule>
108 <rule ref="category/java/design.xml">
109 <exclude name="AvoidCatchingGenericException"/>
110 <exclude name="AvoidDeeplyNestedIfStmts"/>
111 <exclude name="AvoidRethrowingException"/>
112 <exclude name="AvoidUncheckedExceptionsInSignatures" reason="We disagree with the reasoning for making this an issue; a strength of Java is verbosity, and warning users about adding `@throws &lt;? extends RuntimeException&gt;` is probably a bad long-term idea."/>
113 <exclude name="CognitiveComplexity" reason="Introduced in 6.35, some number of positives in source code at this time"/>
114 <exclude name="CollapsibleIfStatements"/>
115 <exclude name="CouplingBetweenObjects"/>
116 <exclude name="CyclomaticComplexity"/>
117 <exclude name="DataClass"/>
118 <exclude name="ExceptionAsFlowControl"/>
119 <exclude name="ExcessiveImports"/>
120 <exclude name="ExcessiveParameterList"/>
121 <exclude name="ExcessivePublicCount"/>
122 <exclude name="GodClass"/>
123 <exclude name="ImmutableField"/>
124 <exclude name="LawOfDemeter"/>
125 <exclude name="LoosePackageCoupling"/>
126 <exclude name="MutableStaticState" reason="Introduced in 6.35, some number of positives in source code at this time"/>
127 <exclude name="NcssCount"/>
128 <exclude name="NPathComplexity"/>
129 <exclude name="SignatureDeclareThrowsException"/>
130 <exclude name="SimplifiedTernary"/>
131 <exclude name="SimplifyBooleanReturns" reason="Increased sensitivity in 7.x; should be fixed in our source code." />
132 <exclude name="SimplifyConditional"/>
133 <exclude name="SingularField"/>
134 <exclude name="SwitchDensity"/>
135 <exclude name="TooManyFields"/>
136 <exclude name="TooManyMethods"/>
137 <exclude name="UseObjectForClearerAPI"/>
138 <exclude name="UselessOverridingMethod"/>
139 <exclude name="UseUtilityClass"/>
140 </rule>
141 <rule ref="category/java/design.xml/SignatureDeclareThrowsException">
142 <properties>
143 <property name="violationSuppressXPath" value="//MethodDeclaration/ModifierList/Annotation[@SimpleName='Override']"/>
144 <property name="IgnoreJUnitCompletely" value="true"/>
145 </properties>
146 </rule>
147 <rule ref="category/java/errorprone.xml">
148 <exclude name="AssignmentInOperand"/>
149 <exclude name="AssignmentToNonFinalStatic"/>
150 <exclude name="AvoidBranchingStatementAsLastInLoop"/>
151 <exclude name="AvoidCatchingNPE"/>
152 <exclude name="AvoidDuplicateLiterals"/>
153 <exclude name="AvoidFieldNameMatchingMethodName"/>
154 <exclude name="AvoidFieldNameMatchingTypeName"/>
155 <exclude name="AvoidInstanceofChecksInCatchClause"/>
156 <exclude name="AvoidLiteralsInIfCondition"/>
157 <exclude name="CompareObjectsWithEquals"/>
158 <exclude name="ConfusingArgumentToVarargsMethod" reason="Introduced in 7.1.0; there are false positives in source code at this time."/>
159 <exclude name="ConstructorCallsOverridableMethod"/>
160 <exclude name="DoNotTerminateVM"/>
161 <exclude name="DontImportSun"/>
162 <exclude name="ImplicitSwitchFallThrough"/>
163 <exclude name="MissingSerialVersionUID"/>
164 <exclude name="MissingStaticMethodInNonInstantiatableClass"/>
165 <exclude name="NonSerializableClass"/>
166 <exclude name="NonStaticInitializer"/>
167 <exclude name="NullAssignment"/>
168 <exclude name="ReturnEmptyCollectionRatherThanNull" reason="Introduced in 6.37, there are positives in source code at this time"/>
169 <exclude name="SimpleDateFormatNeedsLocale"/>
170 <exclude name="SingleMethodSingleton"/>
171 <exclude name="SingletonClassReturningNewInstance"/>
172 <exclude name="TestClassWithoutTestCases"/>
173 <exclude name="UseProperClassLoader"/>
174 </rule>
175 <rule ref="category/java/errorprone.xml/AvoidAccessibilityAlteration">
176 <properties>
177 <property name="violationSuppressXPath" value="//ClassDeclaration[@SimpleName='ReflectionUtils']"/>
178 </properties>
179 </rule>
180 <rule ref="category/java/performance.xml">
181 <exclude name="AvoidInstantiatingObjectsInLoops"/>
182 <exclude name="ConsecutiveLiteralAppends"/>
183 <exclude name="InefficientEmptyStringCheck"/>
184 <exclude name="InsufficientStringBufferDeclaration" reason="PMD 6.40 has a bug where it doesn't properly count appended strings in if statements."/>
185 <exclude name="TooFewBranchesForASwitchStatement"/>
186 <exclude name="UseArrayListInsteadOfVector"/>
187 <exclude name="UselessStringValueOf"/>
188 <exclude name="UseStringBufferForStringAppends"/>
189 </rule>
190
191</ruleset>
Note: See TracBrowser for help on using the repository browser.