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

Last change on this file since 19631 was 19631, checked in by gaben, 3 days ago

see #24635 - re-enable SimplifiedTernary rule and fix the warning

  • Property svn:eol-style set to LF
File size: 9.5 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="LiteralsFirstInComparisons" reason="Introduced in 6.24, some positives in source code at this time. Replaces PositionLiteralsFirstInComparisons."/>
20 <exclude name="LooseCoupling"/>
21 <exclude name="MethodReturnsInternalArray"/>
22 <exclude name="OneDeclarationPerLine"/>
23 <exclude name="ReplaceHashtableWithMap"/>
24 <exclude name="SystemPrintln"/>
25 <exclude name="UnusedAssignment" reason="Introduced in 6.26, some number of positives in source code at this time"/>
26 <exclude name="UseVarargs"/>
27 </rule>
28 <rule ref="category/java/bestpractices.xml/ForLoopCanBeForeach">
29 <properties>
30 <!-- The list is expanded during iteration -->
31 <property name="violationSuppressXPath" value="//ClassDeclaration[@SimpleName='PurgeCommand']/ClassBody/MethodDeclaration[@Name='build']/Block/IfStatement/Block/ForStatement/InfixExpression/MethodCall/VariableAccess[@Name='relLst']"/>
32 </properties>
33 </rule>
34 <rule ref="category/java/bestpractices.xml/AvoidUsingHardCodedIP">
35 <properties>
36 <property name="violationSuppressXPath" value="//ClassDeclaration[@SimpleName='DefaultProxySelector' or @SimpleName='RemoteControl']"/>
37 </properties>
38 </rule>
39 <rule ref="category/java/codestyle.xml">
40 <exclude name="AtLeastOneConstructor"/>
41 <exclude name="BooleanGetMethodName"/>
42 <exclude name="CallSuperInConstructor"/>
43 <exclude name="ClassNamingConventions"/>
44 <exclude name="CommentDefaultAccessModifier"/>
45 <exclude name="ConfusingTernary"/>
46 <exclude name="ControlStatementBraces"/>
47 <!-- EmptyControlStatement is not configurable, so the behavior of the old excludes of EmptyIfStmt/EmptyWhileStmt (errorprone.xml) while getting new functionality cannot be done -->
48 <exclude name="EmptyControlStatement"/>
49 <exclude name="EmptyMethodInAbstractClassShouldBeAbstract"/>
50 <exclude name="FieldDeclarationsShouldBeAtStartOfClass"/>
51 <exclude name="FieldNamingConventions"/>
52 <exclude name="LinguisticNaming"/>
53 <exclude name="LocalVariableCouldBeFinal"/>
54 <exclude name="LongVariable"/>
55 <exclude name="MethodArgumentCouldBeFinal"/>
56 <exclude name="MethodNamingConventions"/>
57 <exclude name="OnlyOneReturn"/>
58 <exclude name="PrematureDeclaration"/>
59 <exclude name="ShortClassName"/>
60 <exclude name="ShortMethodName"/>
61 <exclude name="ShortVariable"/>
62 <exclude name="TooManyStaticImports"/>
63 <exclude name="UnnecessaryCast" reason="Introduced in 6.24, some positives in source code at this time"/>
64 <exclude name="UnnecessaryConstructor"/>
65 <exclude name="UseUnderscoresInNumericLiterals"/>
66 <exclude name="UselessParentheses"/>
67 <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."/>
68 </rule>
69 <rule ref="category/java/codestyle.xml/ShortMethodName">
70 <properties>
71 <property name="violationSuppressXPath" value="//MethodDeclaration[@Name='at' or @Name='ht' or @Name='of' or @Name='ok' or @Name='tr']"/>
72 </properties>
73 </rule>
74 <rule ref="category/java/codestyle.xml/MethodNamingConventions">
75 <properties>
76 <property name="violationSuppressXPath" value="//ClassDeclaration[@SimpleName='Functions' or @SimpleName='PseudoClasses' or @SimpleName='Role' or @SimpleName='TaggingPreset' or @SimpleName='RegionSpecific']"/>
77 </properties>
78 </rule>
79 <rule ref="category/java/codestyle.xml/FieldNamingConventions">
80 <properties>
81 <property name="enumConstantPattern" value="[A-Za-z][A-Za-z_0-9]*"/>
82 <property name="violationSuppressXPath" value="//FieldDeclaration[@Visibility='public']
83 | //FieldDeclaration/ModifierList/Annotation[@SimpleName='StructEntry']
84 | //FieldDeclaration/ClassType[@SimpleName!='Boolean' and
85 @SimpleName!='Byte' and
86 @SimpleName!='Character' and
87 @SimpleName!='Class' and
88 @SimpleName!='Double' and
89 @SimpleName!='Enum' and
90 @SimpleName!='Float' and
91 @SimpleName!='Integer' and
92 @SimpleName!='Long' and
93 @SimpleName!='Number' and
94 @SimpleName!='Short' and
95 @SimpleName!='String' ]"/>
96 </properties>
97 </rule>
98 <rule ref="category/java/codestyle.xml/LongVariable">
99 <properties>
100 <property name="minimum" value="44"/>
101 </properties>
102 </rule>
103 <rule ref="category/java/design.xml">
104 <exclude name="PublicMemberInNonPublicType" reason="Fixing these issues does not improve the code quality, rather the opposite"/>
105 <exclude name="AvoidDeeplyNestedIfStmts"/>
106 <exclude name="AvoidRethrowingException"/>
107 <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."/>
108 <exclude name="CognitiveComplexity" reason="Introduced in 6.35, some number of positives in source code at this time"/>
109 <exclude name="CollapsibleIfStatements"/>
110 <exclude name="CouplingBetweenObjects"/>
111 <exclude name="CyclomaticComplexity"/>
112 <exclude name="DataClass"/>
113 <exclude name="ExceptionAsFlowControl"/>
114 <exclude name="ExcessiveImports"/>
115 <exclude name="ExcessiveParameterList"/>
116 <exclude name="ExcessivePublicCount"/>
117 <exclude name="GodClass"/>
118 <exclude name="ImmutableField"/>
119 <exclude name="LawOfDemeter"/>
120 <exclude name="LoosePackageCoupling"/>
121 <exclude name="MutableStaticState" reason="Introduced in 6.35, some number of positives in source code at this time"/>
122 <exclude name="NcssCount"/>
123 <exclude name="NPathComplexity"/>
124 <exclude name="SignatureDeclareThrowsException"/>
125 <exclude name="SimplifyBooleanReturns" reason="Increased sensitivity in 7.x; should be fixed in our source code." />
126 <exclude name="SingularField"/>
127 <exclude name="SwitchDensity"/>
128 <exclude name="TooManyFields"/>
129 <exclude name="TooManyMethods"/>
130 <exclude name="UselessOverridingMethod"/>
131 </rule>
132 <rule ref="category/java/design.xml/SignatureDeclareThrowsException">
133 <properties>
134 <property name="violationSuppressXPath" value="//MethodDeclaration/ModifierList/Annotation[@SimpleName='Override']"/>
135 <property name="IgnoreJUnitCompletely" value="true"/>
136 </properties>
137 </rule>
138 <rule ref="category/java/errorprone.xml">
139 <exclude name="AvoidCatchingGenericException"/>
140 <exclude name="AssignmentInOperand"/>
141 <exclude name="AssignmentToNonFinalStatic"/>
142 <exclude name="AvoidBranchingStatementAsLastInLoop"/>
143 <exclude name="AvoidDuplicateLiterals"/>
144 <exclude name="AvoidFieldNameMatchingMethodName"/>
145 <exclude name="AvoidFieldNameMatchingTypeName"/>
146 <exclude name="AvoidInstanceofChecksInCatchClause"/>
147 <exclude name="AvoidLiteralsInIfCondition"/>
148 <exclude name="CompareObjectsWithEquals"/>
149 <exclude name="ConfusingArgumentToVarargsMethod" reason="Introduced in 7.1.0; there are false positives in source code at this time."/>
150 <exclude name="ConstructorCallsOverridableMethod"/>
151 <exclude name="DoNotTerminateVM"/>
152 <exclude name="ImplicitSwitchFallThrough"/>
153 <exclude name="MissingSerialVersionUID"/>
154 <exclude name="MissingStaticMethodInNonInstantiatableClass"/>
155 <exclude name="NonSerializableClass"/>
156 <exclude name="NonStaticInitializer"/>
157 <exclude name="NullAssignment"/>
158 <exclude name="ReturnEmptyCollectionRatherThanNull" reason="Introduced in 6.37, there are positives in source code at this time"/>
159 <exclude name="SimpleDateFormatNeedsLocale"/>
160 <exclude name="SingleMethodSingleton"/>
161 <exclude name="SingletonClassReturningNewInstance"/>
162 <exclude name="TestClassWithoutTestCases"/>
163 <exclude name="UseProperClassLoader"/>
164 </rule>
165 <rule ref="category/java/errorprone.xml/AvoidAccessibilityAlteration">
166 <properties>
167 <property name="violationSuppressXPath" value="//ClassDeclaration[@SimpleName='ReflectionUtils']"/>
168 </properties>
169 </rule>
170 <rule ref="category/java/performance.xml">
171 <exclude name="AvoidInstantiatingObjectsInLoops"/>
172 <exclude name="ConsecutiveLiteralAppends"/>
173 <exclude name="InsufficientStringBufferDeclaration" reason="PMD 6.40 has a bug where it doesn't properly count appended strings in if statements."/>
174 <exclude name="UseStringBufferForStringAppends"/>
175 </rule>
176
177</ruleset>
Note: See TracBrowser for help on using the repository browser.