Changeset 19113 in josm for trunk/tools/pmd


Ignore:
Timestamp:
2024-06-18T22:29:22+02:00 (7 months ago)
Author:
taylor.smock
Message:

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:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/pmd/josm-ruleset.xml

    r18918 r19113  
    66
    77  <description>JOSM PMD ruleset</description>
     8  <!-- Generated files -->
     9  <exclude-pattern>.*/org/openstreetmap/josm/gui/mappaint/mapcss/parsergen/.*</exclude-pattern>
    810
    911  <rule ref="category/java/bestpractices.xml">
    10     <exclude name="AccessorClassGeneration"/>
    11     <exclude name="AccessorMethodGeneration"/>
    1212    <exclude name="ArrayIsStoredDirectly"/>
    1313    <exclude name="AvoidPrintStackTrace"/>
     
    1515    <exclude name="AvoidReassigningParameters"/>
    1616    <exclude name="AvoidStringBufferField"/>
    17     <exclude name="AvoidUsingHardCodedIP"/>
    1817    <exclude name="ConstantsInInterface"/>
    19     <exclude name="ForLoopCanBeForeach"/>
    20     <exclude name="ForLoopVariableCount"/>
    2118    <exclude name="GuardLogStatement"/>
    22     <exclude name="JUnit4TestShouldUseAfterAnnotation"/>
    23     <exclude name="JUnit4TestShouldUseTestAnnotation"/>
     19    <exclude name="JUnit4TestShouldUseTestAnnotation" reason="False positive in src/org/openstreetmap/josm/data/validation/Test.java"/>
    2420    <exclude name="LiteralsFirstInComparisons" reason="Introduced in 6.24, some positives in source code at this time. Replaces PositionLiteralsFirstInComparisons."/>
    2521    <exclude name="LooseCoupling"/>
    2622    <exclude name="MethodReturnsInternalArray"/>
    2723    <exclude name="OneDeclarationPerLine"/>
    28     <exclude name="PreserveStackTrace"/>
    2924    <exclude name="ReplaceHashtableWithMap"/>
    3025    <exclude name="SwitchStmtsShouldHaveDefault"/>
    3126    <exclude name="SystemPrintln"/>
    3227    <exclude name="UnusedAssignment" reason="Introduced in 6.26, some number of positives in source code at this time"/>
    33     <exclude name="UnusedFormalParameter"/>
    3428    <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"/>
    3530    <exclude name="UseVarargs"/>
    3631  </rule>
    37   <rule ref="category/java/bestpractices.xml/PreserveStackTrace">
     32  <rule ref="category/java/bestpractices.xml/ForLoopCanBeForeach">
    3833    <properties>
    39         <property name="violationSuppressXPath" value="//PrimaryExpression/PrimaryPrefix/Name[@Image='BugReport.intercept']"/>
     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']"/>
    4036    </properties>
    4137  </rule>
    42   <rule ref="category/java/bestpractices.xml/UnusedFormalParameter">
     38  <rule ref="category/java/bestpractices.xml/AvoidUsingHardCodedIP">
    4339    <properties>
    44         <property name="violationSuppressXPath" value="//Annotation[MarkerAnnotation/Name/@SimpleName='Deprecated']/..[MethodDeclaration|ConstructorDeclaration]"/>
     40      <property name="violationSuppressXPath" value="//ClassDeclaration[@SimpleName='DefaultProxySelector' or @SimpleName='RemoteControl']"/>
    4541    </properties>
    4642  </rule>
    4743  <rule ref="category/java/codestyle.xml">
    48     <exclude name="AbstractNaming"/>
    4944    <exclude name="AtLeastOneConstructor"/>
    50     <exclude name="AvoidFinalLocalVariable"/>
    51     <exclude name="AvoidPrefixingMethodParameters"/>
    5245    <exclude name="BooleanGetMethodName"/>
    5346    <exclude name="CallSuperInConstructor"/>
     
    5649    <exclude name="ConfusingTernary"/>
    5750    <exclude name="ControlStatementBraces"/>
    58     <exclude name="DefaultPackage"/>
    5951    <!-- EmptyControlStatement is not configurable, so the behavior of the old excludes of EmptyIfStmt/EmptyWhileStmt (errorprone.xml) while getting new functionality cannot be done -->
    6052    <exclude name="EmptyControlStatement"/>
     
    6254    <exclude name="FieldDeclarationsShouldBeAtStartOfClass"/>
    6355    <exclude name="FieldNamingConventions"/>
    64     <exclude name="ForLoopsMustUseBraces"/>
    65     <exclude name="IfElseStmtsMustUseBraces"/>
    66     <exclude name="IfStmtsMustUseBraces"/>
    6756    <exclude name="LinguisticNaming"/>
    6857    <exclude name="LocalVariableCouldBeFinal"/>
     
    8170    <exclude name="UseUnderscoresInNumericLiterals"/>
    8271    <exclude name="UselessParentheses"/>
    83     <exclude name="VariableNamingConventions"/>
    84     <exclude name="WhileLoopsMustUseBraces"/>
     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."/>
    8573  </rule>
    8674  <rule ref="category/java/codestyle.xml/ShortMethodName">
    8775    <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']"/>
     76      <property name="violationSuppressXPath" value="//MethodDeclaration[@Name='at' or @Name='ht' or @Name='of' or @Name='ok' or @Name='tr']"/>
    9177    </properties>
    9278  </rule>
    9379  <rule ref="category/java/codestyle.xml/MethodNamingConventions">
    9480    <properties>
    95         <property name="violationSuppressXPath" value="//MethodDeclaration/../../..[@SimpleName='Functions' or @SimpleName='PseudoClasses' or @SimpleName='Role' or @SimpleName='TaggingPreset' or @SimpleName='RegionSpecific']"/>
     81      <property name="violationSuppressXPath" value="//ClassDeclaration[@SimpleName='Functions' or @SimpleName='PseudoClasses' or @SimpleName='Role' or @SimpleName='TaggingPreset' or @SimpleName='RegionSpecific']"/>
    9682    </properties>
    9783  </rule>
     
    9985    <properties>
    10086        <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' ]"/>
     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' ]"/>
    115101    </properties>
    116102  </rule>
     
    124110    <exclude name="AvoidDeeplyNestedIfStmts"/>
    125111    <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."/>
    126113    <exclude name="CognitiveComplexity" reason="Introduced in 6.35, some number of positives in source code at this time"/>
    127114    <exclude name="CollapsibleIfStatements"/>
     
    142129    <exclude name="SignatureDeclareThrowsException"/>
    143130    <exclude name="SimplifiedTernary"/>
     131    <exclude name="SimplifyBooleanReturns" reason="Increased sensitivity in 7.x; should be fixed in our source code." />
    144132    <exclude name="SimplifyConditional"/>
    145133    <exclude name="SingularField"/>
     
    153141  <rule ref="category/java/design.xml/SignatureDeclareThrowsException">
    154142    <properties>
    155         <property name="violationSuppressXPath" value="//MethodDeclaration/../Annotation/MarkerAnnotation/Name[@Image='Override']"/>
     143        <property name="violationSuppressXPath" value="//MethodDeclaration/ModifierList/Annotation[@SimpleName='Override']"/>
    156144        <property name="IgnoreJUnitCompletely" value="true"/>
    157145    </properties>
     
    167155    <exclude name="AvoidInstanceofChecksInCatchClause"/>
    168156    <exclude name="AvoidLiteralsInIfCondition"/>
    169     <exclude name="CloneThrowsCloneNotSupportedException"/>
    170     <!-- <exclude name="CloseResource"/> -->
    171157    <exclude name="CompareObjectsWithEquals"/>
     158    <exclude name="ConfusingArgumentToVarargsMethod" reason="Introduced in 7.1.0; there are false positives in source code at this time."/>
    172159    <exclude name="ConstructorCallsOverridableMethod"/>
    173     <exclude name="DataflowAnomalyAnalysis"/>
    174160    <exclude name="DoNotTerminateVM"/>
    175161    <exclude name="DontImportSun"/>
     
    180166    <exclude name="NonStaticInitializer"/>
    181167    <exclude name="NullAssignment"/>
    182     <exclude name="ReturnEmptyArrayRatherThanNull"/>
    183168    <exclude name="ReturnEmptyCollectionRatherThanNull" reason="Introduced in 6.37, there are positives in source code at this time"/>
    184169    <exclude name="SimpleDateFormatNeedsLocale"/>
     
    190175  <rule ref="category/java/errorprone.xml/AvoidAccessibilityAlteration">
    191176    <properties>
    192       <property name="violationSuppressXPath" value="//MethodDeclaration/../../..[@SimpleName='ReflectionUtils']"/>
     177      <property name="violationSuppressXPath" value="//ClassDeclaration[@SimpleName='ReflectionUtils']"/>
    193178    </properties>
    194179  </rule>
    195180  <rule ref="category/java/performance.xml">
    196181    <exclude name="AvoidInstantiatingObjectsInLoops"/>
    197     <exclude name="AvoidUsingShortType"/>
    198182    <exclude name="ConsecutiveLiteralAppends"/>
    199183    <exclude name="InefficientEmptyStringCheck"/>
    200     <exclude name="SimplifyStartsWith"/>
    201184    <exclude name="InsufficientStringBufferDeclaration" reason="PMD 6.40 has a bug where it doesn't properly count appended strings in if statements."/>
    202185    <exclude name="TooFewBranchesForASwitchStatement"/>
Note: See TracChangeset for help on using the changeset viewer.