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

Last change on this file was 18918, checked in by taylor.smock, 4 months ago

Fix #23290: Validate the regions a tag is expected to be in (patch by Sarabjeet108, modified)

Modifications are as follows:

  • Allow the use of the new region attributes for keys inside a preset
  • Basic tests

regions comes from Vespucci's extensions: https://vespucci.io/tutorials/presets/#extensions

File size: 10.7 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
9 <rule ref="category/java/bestpractices.xml">
10 <exclude name="AccessorClassGeneration"/>
11 <exclude name="AccessorMethodGeneration"/>
12 <exclude name="ArrayIsStoredDirectly"/>
13 <exclude name="AvoidPrintStackTrace"/>
14 <exclude name="AvoidReassigningLoopVariables"/>
15 <exclude name="AvoidReassigningParameters"/>
16 <exclude name="AvoidStringBufferField"/>
17 <exclude name="AvoidUsingHardCodedIP"/>
18 <exclude name="ConstantsInInterface"/>
19 <exclude name="ForLoopCanBeForeach"/>
20 <exclude name="ForLoopVariableCount"/>
21 <exclude name="GuardLogStatement"/>
22 <exclude name="JUnit4TestShouldUseAfterAnnotation"/>
23 <exclude name="JUnit4TestShouldUseTestAnnotation"/>
24 <exclude name="LiteralsFirstInComparisons" reason="Introduced in 6.24, some positives in source code at this time. Replaces PositionLiteralsFirstInComparisons."/>
25 <exclude name="LooseCoupling"/>
26 <exclude name="MethodReturnsInternalArray"/>
27 <exclude name="OneDeclarationPerLine"/>
28 <exclude name="PreserveStackTrace"/>
29 <exclude name="ReplaceHashtableWithMap"/>
30 <exclude name="SwitchStmtsShouldHaveDefault"/>
31 <exclude name="SystemPrintln"/>
32 <exclude name="UnusedAssignment" reason="Introduced in 6.26, some number of positives in source code at this time"/>
33 <exclude name="UnusedFormalParameter"/>
34 <exclude name="UnusedPrivateMethod" reason="Broken since PMD 6.33, see https://github.com/pmd/pmd/issues/3468"/>
35 <exclude name="UseVarargs"/>
36 </rule>
37 <rule ref="category/java/bestpractices.xml/PreserveStackTrace">
38 <properties>
39 <property name="violationSuppressXPath" value="//PrimaryExpression/PrimaryPrefix/Name[@Image='BugReport.intercept']"/>
40 </properties>
41 </rule>
42 <rule ref="category/java/bestpractices.xml/UnusedFormalParameter">
43 <properties>
44 <property name="violationSuppressXPath" value="//Annotation[MarkerAnnotation/Name/@SimpleName='Deprecated']/..[MethodDeclaration|ConstructorDeclaration]"/>
45 </properties>
46 </rule>
47 <rule ref="category/java/codestyle.xml">
48 <exclude name="AbstractNaming"/>
49 <exclude name="AtLeastOneConstructor"/>
50 <exclude name="AvoidFinalLocalVariable"/>
51 <exclude name="AvoidPrefixingMethodParameters"/>
52 <exclude name="BooleanGetMethodName"/>
53 <exclude name="CallSuperInConstructor"/>
54 <exclude name="ClassNamingConventions"/>
55 <exclude name="CommentDefaultAccessModifier"/>
56 <exclude name="ConfusingTernary"/>
57 <exclude name="ControlStatementBraces"/>
58 <exclude name="DefaultPackage"/>
59 <!-- EmptyControlStatement is not configurable, so the behavior of the old excludes of EmptyIfStmt/EmptyWhileStmt (errorprone.xml) while getting new functionality cannot be done -->
60 <exclude name="EmptyControlStatement"/>
61 <exclude name="EmptyMethodInAbstractClassShouldBeAbstract"/>
62 <exclude name="FieldDeclarationsShouldBeAtStartOfClass"/>
63 <exclude name="FieldNamingConventions"/>
64 <exclude name="ForLoopsMustUseBraces"/>
65 <exclude name="IfElseStmtsMustUseBraces"/>
66 <exclude name="IfStmtsMustUseBraces"/>
67 <exclude name="LinguisticNaming"/>
68 <exclude name="LocalVariableCouldBeFinal"/>
69 <exclude name="LongVariable"/>
70 <exclude name="MethodArgumentCouldBeFinal"/>
71 <exclude name="MethodNamingConventions"/>
72 <exclude name="NoPackage"/>
73 <exclude name="OnlyOneReturn"/>
74 <exclude name="PrematureDeclaration"/>
75 <exclude name="ShortClassName"/>
76 <exclude name="ShortMethodName"/>
77 <exclude name="ShortVariable"/>
78 <exclude name="TooManyStaticImports"/>
79 <exclude name="UnnecessaryCast" reason="Introduced in 6.24, some positives in source code at this time"/>
80 <exclude name="UnnecessaryConstructor"/>
81 <exclude name="UseUnderscoresInNumericLiterals"/>
82 <exclude name="UselessParentheses"/>
83 <exclude name="VariableNamingConventions"/>
84 <exclude name="WhileLoopsMustUseBraces"/>
85 </rule>
86 <rule ref="category/java/codestyle.xml/ShortMethodName">
87 <properties>
88 <property name="violationSuppressXPath" value="//MethodDeclaration[@Name='at' or @Name='ht' or @Name='of' or @Name='ok' or @Name='tr']
89 | //MethodDeclaration/../../Annotation/MarkerAnnotation/Name[@Image='Deprecated']
90 | //MethodDeclaration/../../../..[@Image='LambertConformalConic']"/>
91 </properties>
92 </rule>
93 <rule ref="category/java/codestyle.xml/MethodNamingConventions">
94 <properties>
95 <property name="violationSuppressXPath" value="//MethodDeclaration/../../..[@SimpleName='Functions' or @SimpleName='PseudoClasses' or @SimpleName='Role' or @SimpleName='TaggingPreset' or @SimpleName='RegionSpecific']"/>
96 </properties>
97 </rule>
98 <rule ref="category/java/codestyle.xml/FieldNamingConventions">
99 <properties>
100 <property name="enumConstantPattern" value="[A-Za-z][A-Za-z_0-9]*"/>
101 <property name="violationSuppressXPath" value="//FieldDeclaration[@Public='true']
102 | //FieldDeclaration/../Annotation/MarkerAnnotation/Name[@Image='pref']
103 | //FieldDeclaration/Type/ReferenceType/ClassOrInterfaceType[@Image!='Boolean' and
104 @Image!='Byte' and
105 @Image!='Character' and
106 @Image!='Class' and
107 @Image!='Double' and
108 @Image!='Enum' and
109 @Image!='Float' and
110 @Image!='Integer' and
111 @Image!='Long' and
112 @Image!='Number' and
113 @Image!='Short' and
114 @Image!='String' ]"/>
115 </properties>
116 </rule>
117 <rule ref="category/java/codestyle.xml/LongVariable">
118 <properties>
119 <property name="minimum" value="44"/>
120 </properties>
121 </rule>
122 <rule ref="category/java/design.xml">
123 <exclude name="AvoidCatchingGenericException"/>
124 <exclude name="AvoidDeeplyNestedIfStmts"/>
125 <exclude name="AvoidRethrowingException"/>
126 <exclude name="CognitiveComplexity" reason="Introduced in 6.35, some number of positives in source code at this time"/>
127 <exclude name="CollapsibleIfStatements"/>
128 <exclude name="CouplingBetweenObjects"/>
129 <exclude name="CyclomaticComplexity"/>
130 <exclude name="DataClass"/>
131 <exclude name="ExceptionAsFlowControl"/>
132 <exclude name="ExcessiveImports"/>
133 <exclude name="ExcessiveParameterList"/>
134 <exclude name="ExcessivePublicCount"/>
135 <exclude name="GodClass"/>
136 <exclude name="ImmutableField"/>
137 <exclude name="LawOfDemeter"/>
138 <exclude name="LoosePackageCoupling"/>
139 <exclude name="MutableStaticState" reason="Introduced in 6.35, some number of positives in source code at this time"/>
140 <exclude name="NcssCount"/>
141 <exclude name="NPathComplexity"/>
142 <exclude name="SignatureDeclareThrowsException"/>
143 <exclude name="SimplifiedTernary"/>
144 <exclude name="SimplifyConditional"/>
145 <exclude name="SingularField"/>
146 <exclude name="SwitchDensity"/>
147 <exclude name="TooManyFields"/>
148 <exclude name="TooManyMethods"/>
149 <exclude name="UseObjectForClearerAPI"/>
150 <exclude name="UselessOverridingMethod"/>
151 <exclude name="UseUtilityClass"/>
152 </rule>
153 <rule ref="category/java/design.xml/SignatureDeclareThrowsException">
154 <properties>
155 <property name="violationSuppressXPath" value="//MethodDeclaration/../Annotation/MarkerAnnotation/Name[@Image='Override']"/>
156 <property name="IgnoreJUnitCompletely" value="true"/>
157 </properties>
158 </rule>
159 <rule ref="category/java/errorprone.xml">
160 <exclude name="AssignmentInOperand"/>
161 <exclude name="AssignmentToNonFinalStatic"/>
162 <exclude name="AvoidBranchingStatementAsLastInLoop"/>
163 <exclude name="AvoidCatchingNPE"/>
164 <exclude name="AvoidDuplicateLiterals"/>
165 <exclude name="AvoidFieldNameMatchingMethodName"/>
166 <exclude name="AvoidFieldNameMatchingTypeName"/>
167 <exclude name="AvoidInstanceofChecksInCatchClause"/>
168 <exclude name="AvoidLiteralsInIfCondition"/>
169 <exclude name="CloneThrowsCloneNotSupportedException"/>
170 <!-- <exclude name="CloseResource"/> -->
171 <exclude name="CompareObjectsWithEquals"/>
172 <exclude name="ConstructorCallsOverridableMethod"/>
173 <exclude name="DataflowAnomalyAnalysis"/>
174 <exclude name="DoNotTerminateVM"/>
175 <exclude name="DontImportSun"/>
176 <exclude name="ImplicitSwitchFallThrough"/>
177 <exclude name="MissingSerialVersionUID"/>
178 <exclude name="MissingStaticMethodInNonInstantiatableClass"/>
179 <exclude name="NonSerializableClass"/>
180 <exclude name="NonStaticInitializer"/>
181 <exclude name="NullAssignment"/>
182 <exclude name="ReturnEmptyArrayRatherThanNull"/>
183 <exclude name="ReturnEmptyCollectionRatherThanNull" reason="Introduced in 6.37, there are positives in source code at this time"/>
184 <exclude name="SimpleDateFormatNeedsLocale"/>
185 <exclude name="SingleMethodSingleton"/>
186 <exclude name="SingletonClassReturningNewInstance"/>
187 <exclude name="TestClassWithoutTestCases"/>
188 <exclude name="UseProperClassLoader"/>
189 </rule>
190 <rule ref="category/java/errorprone.xml/AvoidAccessibilityAlteration">
191 <properties>
192 <property name="violationSuppressXPath" value="//MethodDeclaration/../../..[@SimpleName='ReflectionUtils']"/>
193 </properties>
194 </rule>
195 <rule ref="category/java/performance.xml">
196 <exclude name="AvoidInstantiatingObjectsInLoops"/>
197 <exclude name="AvoidUsingShortType"/>
198 <exclude name="ConsecutiveLiteralAppends"/>
199 <exclude name="InefficientEmptyStringCheck"/>
200 <exclude name="SimplifyStartsWith"/>
201 <exclude name="InsufficientStringBufferDeclaration" reason="PMD 6.40 has a bug where it doesn't properly count appended strings in if statements."/>
202 <exclude name="TooFewBranchesForASwitchStatement"/>
203 <exclude name="UseArrayListInsteadOfVector"/>
204 <exclude name="UselessStringValueOf"/>
205 <exclude name="UseStringBufferForStringAppends"/>
206 </rule>
207
208</ruleset>
Note: See TracBrowser for help on using the repository browser.