| 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 |
<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 |
|
| 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 |
|
| 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="PublicMemberInNonPublicType" reason="Fixing these issues does not improve the code quality, rather the opposite"/> |
| 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 <? extends RuntimeException>` 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="AvoidCatchingGenericException"/> |
| 149 |
<exclude name="AssignmentInOperand"/> |
| 150 |
<exclude name="AssignmentToNonFinalStatic"/> |
| 151 |
<exclude name="AvoidBranchingStatementAsLastInLoop"/> |
| 152 |
<exclude name="AvoidCatchingNPE"/> |
| 153 |
<exclude name="AvoidDuplicateLiterals"/> |
| 154 |
<exclude name="AvoidFieldNameMatchingMethodName"/> |
| 155 |
<exclude name="AvoidFieldNameMatchingTypeName"/> |
| 156 |
<exclude name="AvoidInstanceofChecksInCatchClause"/> |
| 157 |
<exclude name="AvoidLiteralsInIfCondition"/> |
| 158 |
<exclude name="CompareObjectsWithEquals"/> |
| 159 |
<exclude name="ConfusingArgumentToVarargsMethod" reason="Introduced in 7.1.0; there are false positives in source code at this time."/> |
| 160 |
<exclude name="ConstructorCallsOverridableMethod"/> |
| 161 |
<exclude name="DoNotTerminateVM"/> |
| 162 |
<exclude name="DontImportSun"/> |
| 163 |
<exclude name="ImplicitSwitchFallThrough"/> |
| 164 |
<exclude name="MissingSerialVersionUID"/> |
| 165 |
<exclude name="MissingStaticMethodInNonInstantiatableClass"/> |
| 166 |
<exclude name="NonSerializableClass"/> |
| 167 |
<exclude name="NonStaticInitializer"/> |
| 168 |
<exclude name="NullAssignment"/> |
| 169 |
<exclude name="ReturnEmptyCollectionRatherThanNull" reason="Introduced in 6.37, there are positives in source code at this time"/> |
| 170 |
<exclude name="SimpleDateFormatNeedsLocale"/> |
| 171 |
<exclude name="SingleMethodSingleton"/> |
| 172 |
<exclude name="SingletonClassReturningNewInstance"/> |
| 173 |
<exclude name="TestClassWithoutTestCases"/> |
| 174 |
<exclude name="UseProperClassLoader"/> |
| 175 |
</rule> |
| 176 |
<rule ref="category/java/errorprone.xml/AvoidAccessibilityAlteration"> |
| 177 |
<properties> |
| 178 |
<property name="violationSuppressXPath" value="//ClassDeclaration[@SimpleName='ReflectionUtils']"/> |
| 179 |
</properties> |
| 180 |
</rule> |
| 181 |
<rule ref="category/java/performance.xml"> |
| 182 |
<exclude name="AvoidInstantiatingObjectsInLoops"/> |
| 183 |
<exclude name="ConsecutiveLiteralAppends"/> |
| 184 |
<exclude name="InefficientEmptyStringCheck"/> |
| 185 |
<exclude name="InsufficientStringBufferDeclaration" reason="PMD 6.40 has a bug where it doesn't properly count appended strings in if statements."/> |
| 186 |
<exclude name="TooFewBranchesForASwitchStatement"/> |
| 187 |
<exclude name="UseArrayListInsteadOfVector"/> |
| 188 |
<exclude name="UselessStringValueOf"/> |
| 189 |
<exclude name="UseStringBufferForStringAppends"/> |
| 190 |
</rule> |
| 191 |
|
| 192 |
</ruleset> |