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

Last change on this file since 19234 was 19113, checked in by taylor.smock, 4 months 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
RevLine 
[11713]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"
[18629]5 xsi:schemaLocation="http://pmd.sourceforge.net/ruleset/2.0.0 https://pmd.sourceforge.io/ruleset_2_0_0.xsd">
[18332]6
[11713]7 <description>JOSM PMD ruleset</description>
[19113]8 <!-- Generated files -->
9 <exclude-pattern>.*/org/openstreetmap/josm/gui/mappaint/mapcss/parsergen/.*</exclude-pattern>
[18332]10
[13202]11 <rule ref="category/java/bestpractices.xml">
12 <exclude name="ArrayIsStoredDirectly"/>
13 <exclude name="AvoidPrintStackTrace"/>
[15588]14 <exclude name="AvoidReassigningLoopVariables"/>
[13202]15 <exclude name="AvoidReassigningParameters"/>
16 <exclude name="AvoidStringBufferField"/>
17 <exclude name="ConstantsInInterface"/>
18 <exclude name="GuardLogStatement"/>
[19113]19 <exclude name="JUnit4TestShouldUseTestAnnotation" reason="False positive in src/org/openstreetmap/josm/data/validation/Test.java"/>
[18332]20 <exclude name="LiteralsFirstInComparisons" reason="Introduced in 6.24, some positives in source code at this time. Replaces PositionLiteralsFirstInComparisons."/>
[13202]21 <exclude name="LooseCoupling"/>
22 <exclude name="MethodReturnsInternalArray"/>
23 <exclude name="OneDeclarationPerLine"/>
24 <exclude name="ReplaceHashtableWithMap"/>
25 <exclude name="SwitchStmtsShouldHaveDefault"/>
26 <exclude name="SystemPrintln"/>
[18332]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"/>
[19113]29 <exclude name="UnusedPrivateField" reason="Broken in 7.2.x"/>
[13202]30 <exclude name="UseVarargs"/>
[12539]31 </rule>
[19113]32 <rule ref="category/java/bestpractices.xml/ForLoopCanBeForeach">
[13207]33 <properties>
[19113]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']"/>
[13207]36 </properties>
37 </rule>
[19113]38 <rule ref="category/java/bestpractices.xml/AvoidUsingHardCodedIP">
[12539]39 <properties>
[19113]40 <property name="violationSuppressXPath" value="//ClassDeclaration[@SimpleName='DefaultProxySelector' or @SimpleName='RemoteControl']"/>
[13202]41 </properties>
42 </rule>
43 <rule ref="category/java/codestyle.xml">
44 <exclude name="AtLeastOneConstructor"/>
45 <exclude name="BooleanGetMethodName"/>
46 <exclude name="CallSuperInConstructor"/>
[13719]47 <exclude name="ClassNamingConventions"/>
[13202]48 <exclude name="CommentDefaultAccessModifier"/>
49 <exclude name="ConfusingTernary"/>
[13595]50 <exclude name="ControlStatementBraces"/>
[18514]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"/>
[13202]53 <exclude name="EmptyMethodInAbstractClassShouldBeAbstract"/>
54 <exclude name="FieldDeclarationsShouldBeAtStartOfClass"/>
[14604]55 <exclude name="FieldNamingConventions"/>
56 <exclude name="LinguisticNaming"/>
[13202]57 <exclude name="LocalVariableCouldBeFinal"/>
58 <exclude name="LongVariable"/>
59 <exclude name="MethodArgumentCouldBeFinal"/>
60 <exclude name="MethodNamingConventions"/>
[14638]61 <exclude name="NoPackage"/>
[13202]62 <exclude name="OnlyOneReturn"/>
63 <exclude name="PrematureDeclaration"/>
64 <exclude name="ShortClassName"/>
65 <exclude name="ShortMethodName"/>
66 <exclude name="ShortVariable"/>
67 <exclude name="TooManyStaticImports"/>
[18332]68 <exclude name="UnnecessaryCast" reason="Introduced in 6.24, some positives in source code at this time"/>
[13202]69 <exclude name="UnnecessaryConstructor"/>
[18332]70 <exclude name="UseUnderscoresInNumericLiterals"/>
[13202]71 <exclude name="UselessParentheses"/>
[19113]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."/>
[13202]73 </rule>
74 <rule ref="category/java/codestyle.xml/ShortMethodName">
75 <properties>
[19113]76 <property name="violationSuppressXPath" value="//MethodDeclaration[@Name='at' or @Name='ht' or @Name='of' or @Name='ok' or @Name='tr']"/>
[12539]77 </properties>
78 </rule>
[13202]79 <rule ref="category/java/codestyle.xml/MethodNamingConventions">
[12539]80 <properties>
[19113]81 <property name="violationSuppressXPath" value="//ClassDeclaration[@SimpleName='Functions' or @SimpleName='PseudoClasses' or @SimpleName='Role' or @SimpleName='TaggingPreset' or @SimpleName='RegionSpecific']"/>
[12539]82 </properties>
83 </rule>
[14604]84 <rule ref="category/java/codestyle.xml/FieldNamingConventions">
[12539]85 <properties>
[14604]86 <property name="enumConstantPattern" value="[A-Za-z][A-Za-z_0-9]*"/>
[19113]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' ]"/>
[12539]101 </properties>
102 </rule>
[13202]103 <rule ref="category/java/codestyle.xml/LongVariable">
[12539]104 <properties>
105 <property name="minimum" value="44"/>
106 </properties>
107 </rule>
[13202]108 <rule ref="category/java/design.xml">
109 <exclude name="AvoidCatchingGenericException"/>
110 <exclude name="AvoidDeeplyNestedIfStmts"/>
111 <exclude name="AvoidRethrowingException"/>
[19113]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."/>
[18332]113 <exclude name="CognitiveComplexity" reason="Introduced in 6.35, some number of positives in source code at this time"/>
[13202]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"/>
[18332]126 <exclude name="MutableStaticState" reason="Introduced in 6.35, some number of positives in source code at this time"/>
[13202]127 <exclude name="NcssCount"/>
128 <exclude name="NPathComplexity"/>
129 <exclude name="SignatureDeclareThrowsException"/>
130 <exclude name="SimplifiedTernary"/>
[19113]131 <exclude name="SimplifyBooleanReturns" reason="Increased sensitivity in 7.x; should be fixed in our source code." />
[13202]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"/>
[11930]140 </rule>
[13202]141 <rule ref="category/java/design.xml/SignatureDeclareThrowsException">
[11739]142 <properties>
[19113]143 <property name="violationSuppressXPath" value="//MethodDeclaration/ModifierList/Annotation[@SimpleName='Override']"/>
[11739]144 <property name="IgnoreJUnitCompletely" value="true"/>
145 </properties>
146 </rule>
[13202]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"/>
[19113]158 <exclude name="ConfusingArgumentToVarargsMethod" reason="Introduced in 7.1.0; there are false positives in source code at this time."/>
[13202]159 <exclude name="ConstructorCallsOverridableMethod"/>
[18332]160 <exclude name="DoNotTerminateVM"/>
[13202]161 <exclude name="DontImportSun"/>
[18332]162 <exclude name="ImplicitSwitchFallThrough"/>
[13202]163 <exclude name="MissingSerialVersionUID"/>
164 <exclude name="MissingStaticMethodInNonInstantiatableClass"/>
[18629]165 <exclude name="NonSerializableClass"/>
[13202]166 <exclude name="NonStaticInitializer"/>
167 <exclude name="NullAssignment"/>
[18332]168 <exclude name="ReturnEmptyCollectionRatherThanNull" reason="Introduced in 6.37, there are positives in source code at this time"/>
[13202]169 <exclude name="SimpleDateFormatNeedsLocale"/>
170 <exclude name="SingleMethodSingleton"/>
171 <exclude name="SingletonClassReturningNewInstance"/>
172 <exclude name="TestClassWithoutTestCases"/>
173 <exclude name="UseProperClassLoader"/>
[11739]174 </rule>
[18332]175 <rule ref="category/java/errorprone.xml/AvoidAccessibilityAlteration">
176 <properties>
[19113]177 <property name="violationSuppressXPath" value="//ClassDeclaration[@SimpleName='ReflectionUtils']"/>
[18332]178 </properties>
179 </rule>
[13202]180 <rule ref="category/java/performance.xml">
181 <exclude name="AvoidInstantiatingObjectsInLoops"/>
182 <exclude name="ConsecutiveLiteralAppends"/>
183 <exclude name="InefficientEmptyStringCheck"/>
[18332]184 <exclude name="InsufficientStringBufferDeclaration" reason="PMD 6.40 has a bug where it doesn't properly count appended strings in if statements."/>
[13202]185 <exclude name="TooFewBranchesForASwitchStatement"/>
186 <exclude name="UseArrayListInsteadOfVector"/>
187 <exclude name="UselessStringValueOf"/>
188 <exclude name="UseStringBufferForStringAppends"/>
[11713]189 </rule>
190
[13220]191</ruleset>
Note: See TracBrowser for help on using the repository browser.