Changeset 19113 in josm


Ignore:
Timestamp:
2024-06-18T22:29:22+02:00 (6 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.

Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/ivy.xml

    r19084 r19113  
    2828        <!-- parsson is an implementation for jakarta.json -->
    2929        <dependency conf="runtimeOnly->default" org="org.eclipse.parsson" name="parsson" rev="1.1.6"/>
    30         <dependency conf="api->default" org="org.apache.commons" name="commons-jcs3-core" rev="3.2"/>
    31         <dependency conf="api->default" org="org.apache.commons" name="commons-compress" rev="1.26.1"/>
     30        <dependency conf="api->default" org="org.apache.commons" name="commons-jcs3-core" rev="3.2.1"/>
     31        <dependency conf="api->default" org="org.apache.commons" name="commons-compress" rev="1.26.2"/>
    3232        <dependency conf="api->default" org="jakarta.annotation" name="jakarta.annotation-api" rev="2.1.1" />
    3333        <!-- jsr305 has some source files with non-free CC-BY-2.5 license. Remove after 2024-06-01 to give plugins time to migrate. See #23220 for details -->
     
    4646        <dependency conf="sources->sources" org="jakarta.json" name="jakarta.json-api" rev="2.1.3"/>
    4747        <dependency conf="sources->sources" org="org.eclipse.parsson" name="parsson" rev="1.1.6"/>
    48         <dependency conf="sources->sources" org="org.apache.commons" name="commons-jcs3-core" rev="3.2"/>
    49         <dependency conf="sources->sources" org="org.apache.commons" name="commons-compress" rev="1.26.1"/>
     48        <dependency conf="sources->sources" org="org.apache.commons" name="commons-jcs3-core" rev="3.2.1"/>
     49        <dependency conf="sources->sources" org="org.apache.commons" name="commons-compress" rev="1.26.2"/>
    5050        <dependency conf="sources->sources" org="jakarta.annotation" name="jakarta.annotation-api" rev="2.1.1" />
    5151        <!-- jsr305 has some source files with non-free CC-BY-2.5 license. Remove after 2024-06-01 to give plugins time to migrate. See #23220 for details -->
     
    6565        <dependency conf="jmockit->default" org="org.jmockit" name="jmockit" rev="1.49.a"/>
    6666        <!-- test->default -->
    67         <dependency conf="test->default" org="com.github.spotbugs" name="spotbugs-annotations" rev="4.8.4"/>
     67        <dependency conf="test->default" org="com.github.spotbugs" name="spotbugs-annotations" rev="4.8.5"/>
    6868        <dependency conf="test->default" org="com.ginsberg" name="junit5-system-exit" rev="1.1.2"/>
    69         <dependency conf="test->default" org="org.wiremock" name="wiremock" rev="3.5.4"/>
    70         <dependency conf="test->default" org="io.github.classgraph" name="classgraph" rev="4.8.171"/>
     69        <dependency conf="test->default" org="org.wiremock" name="wiremock" rev="3.6.0"/>
     70        <dependency conf="test->default" org="io.github.classgraph" name="classgraph" rev="4.8.173"/>
    7171        <dependency conf="test->default" org="org.junit.platform" name="junit-platform-launcher" rev="1.10.2"/>
    7272        <dependency conf="test->default" org="org.junit.platform" name="junit-platform-suite" rev="1.10.2"/>
  • trunk/nodist/pom.xml

    r19097 r19113  
    1212        <java.lang.version>11</java.lang.version>
    1313        <maven.compiler.release>${java.lang.version}</maven.compiler.release>
     14        <maven.compiler.source>${maven.compiler.release}</maven.compiler.source>
     15        <maven.compiler.target>${maven.compiler.release}</maven.compiler.target>
    1416        <test.headless>true</test.headless>
    1517        <sonar.host.url>https://josm.openstreetmap.de/sonar/</sonar.host.url>
    1618        <sonar.projectKey>JOSM</sonar.projectKey>
    1719        <jmockit.version>1.49.a</jmockit.version>
     20        <pmd.version>7.2.0</pmd.version>
    1821    </properties>
    1922    <modules>
     
    7275                    <groupId>org.apache.maven.plugins</groupId>
    7376                    <artifactId>maven-pmd-plugin</artifactId>
    74                     <version>3.22.0</version>
     77                    <version>3.23.0</version>
     78                    <dependencies>
     79                        <dependency>
     80                            <groupId>net.sourceforge.pmd</groupId>
     81                            <artifactId>pmd-core</artifactId>
     82                            <version>${pmd.version}</version>
     83                        </dependency>
     84                        <dependency>
     85                            <groupId>net.sourceforge.pmd</groupId>
     86                            <artifactId>pmd-java</artifactId>
     87                            <version>${pmd.version}</version>
     88                        </dependency>
     89                        <dependency>
     90                            <groupId>net.sourceforge.pmd</groupId>
     91                            <artifactId>pmd-javascript</artifactId>
     92                            <version>${pmd.version}</version>
     93                        </dependency>
     94                        <dependency>
     95                            <groupId>net.sourceforge.pmd</groupId>
     96                            <artifactId>pmd-jsp</artifactId>
     97                            <version>${pmd.version}</version>
     98                        </dependency>
     99                    </dependencies>
     100                    <configuration>
     101                      <targetJdk>${java.lang.version}</targetJdk>
     102                    </configuration>
    75103                </plugin>
    76104                <plugin>
     
    201229        <dependencies>
    202230            <dependency>
     231                <groupId>org.jmockit</groupId>
     232                <artifactId>jmockit</artifactId>
     233                <version>${jmockit.version}</version>
     234                <scope>test</scope>
     235            </dependency>
     236            <dependency>
    203237                <groupId>org.junit</groupId>
    204238                <artifactId>junit-bom</artifactId>
     
    228262                <groupId>org.apache.commons</groupId>
    229263                <artifactId>commons-jcs3-core</artifactId>
    230                 <version>3.2</version>
     264                <version>3.2.1</version>
    231265                <scope>provided</scope>
    232266            </dependency>
     
    234268                <groupId>org.apache.commons</groupId>
    235269                <artifactId>commons-compress</artifactId>
    236                 <version>1.26.1</version>
     270                <version>1.26.2</version>
    237271                <scope>provided</scope>
    238272            </dependency>
     
    287321            </dependency>
    288322            <dependency>
    289                 <groupId>org.jmockit</groupId>
    290                 <artifactId>jmockit</artifactId>
    291                 <version>${jmockit.version}</version>
    292                 <scope>test</scope>
    293             </dependency>
    294             <dependency>
    295323                <groupId>com.github.spotbugs</groupId>
    296324                <artifactId>spotbugs-annotations</artifactId>
     
    313341                <groupId>io.github.classgraph</groupId>
    314342                <artifactId>classgraph</artifactId>
    315                 <version>4.8.172</version>
     343                <version>4.8.173</version>
    316344                <scope>test</scope>
    317345            </dependency>
  • trunk/scripts/TagInfoExtract.java

    r19108 r19113  
    103103     * Main method.
    104104     * @param args Main program arguments
    105      * @throws Exception if any error occurs
     105     * @throws IOException if an IO exception occurs
     106     * @throws OsmTransferException if something happened when communicating with the OSM server
     107     * @throws ParseException if there was an issue parsing MapCSS
     108     * @throws SAXException if there was an issue parsing XML
    106109     */
    107     public static void main(String[] args) throws Exception {
     110    public static void main(String[] args) throws IOException, OsmTransferException, ParseException, SAXException {
    108111        HttpClient.setFactory(Http1Client::new);
    109112        TagInfoExtract script = new TagInfoExtract();
  • trunk/src/org/openstreetmap/josm/data/projection/CustomProjection.java

    r19108 r19113  
    3838import org.openstreetmap.josm.tools.Utils;
    3939import org.openstreetmap.josm.tools.bugreport.BugReport;
     40import org.openstreetmap.josm.tools.bugreport.ReportedException;
    4041
    4142/**
     
    223224     * @param pref the string that defines the custom projection
    224225     */
    225     @SuppressWarnings("PMD.PreserveStackTrace") // PMD 7.2.x doesn't like log + new exception here for some reason.
    226226    public CustomProjection(String name, String code, String pref) {
    227227        this.name = name;
     
    235235                update(null);
    236236            } catch (ProjectionConfigurationException ex1) {
    237                 throw BugReport.intercept(ex1).put("name", name).put("code", code).put("pref", pref);
     237                ReportedException reportedException = BugReport.intercept(ex1).put("name", name).put("code", code).put("pref", pref);
     238                reportedException.addSuppressed(ex);
     239                throw reportedException;
    238240            }
    239241        }
  • trunk/tools/ivy.xml

    r19048 r19113  
    1717        <dependency org="net.java.dev.javacc" name="javacc" rev="7.0.13" conf="javacc->default"/>
    1818        <!-- checkstyle->default -->
    19         <dependency org="com.puppycrawl.tools" name="checkstyle" rev="10.15.0" conf="checkstyle->default"/>
     19        <dependency org="com.puppycrawl.tools" name="checkstyle" rev="10.17.0" conf="checkstyle->default"/>
    2020        <!-- proguard->default -->
    21         <dependency org="com.guardsquare" name="proguard-ant" rev="7.4.2" conf="proguard->default"/>
     21        <dependency org="com.guardsquare" name="proguard-ant" rev="7.5.0" conf="proguard->default"/>
    2222        <!-- pmd->default -->
    23         <!-- PMD 7.0.0 has too many false positives right now. When updating, don't forget to add pmd-ant as a new dependency -->
    24         <dependency org="net.sourceforge.pmd" name="pmd-core" rev="6.55.0" conf="pmd->default"/>
    25         <dependency org="net.sourceforge.pmd" name="pmd-java" rev="6.55.0" conf="pmd->default"/>
    26         <dependency org="net.sourceforge.saxon" name="saxon" rev="9.1.0.8" conf="pmd->default">
    27             <artifact name="saxon" type="jar"/>
    28             <artifact name="saxon" type="jar" maven:classifier="dom"/>
    29         </dependency>
     23        <dependency org="net.sourceforge.pmd" name="pmd-core" rev="7.2.0" conf="pmd->default"/>
     24        <dependency org="net.sourceforge.pmd" name="pmd-ant" rev="7.2.0" conf="pmd->default"/>
     25        <dependency org="net.sourceforge.pmd" name="pmd-java" rev="7.2.0" conf="pmd->default"/>
     26        <dependency org="org.xmlresolver" name="xmlresolver" rev="6.0.4" conf="pmd->default"/>
    3027        <!-- spotbugs->default -->
    31         <dependency org="com.github.spotbugs" name="spotbugs" rev="4.8.4" conf="spotbugs->default"/>
    32         <dependency org="com.github.spotbugs" name="spotbugs-ant" rev="4.8.4" conf="spotbugs->default"/>
     28        <dependency org="com.github.spotbugs" name="spotbugs" rev="4.8.5" conf="spotbugs->default"/>
     29        <dependency org="com.github.spotbugs" name="spotbugs-ant" rev="4.8.5" conf="spotbugs->default"/>
    3330        <!-- errorprone->default -->
    34         <dependency org="com.google.errorprone" name="error_prone_core" rev="2.26.1" conf="errorprone->default"/>
     31        <dependency org="com.google.errorprone" name="error_prone_core" rev="2.28.0" conf="errorprone->default"/>
    3532        <!-- animal->default -->
    3633        <dependency org="org.codehaus.mojo" name="animal-sniffer-ant-tasks" rev="1.23" conf="animal->default"/>
  • 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.