Uploaded image for project: 'Maven PMD Plugin'
  1. Maven PMD Plugin
  2. MPMD-310

Unable to find referenced rule AvoidReassigningCatchVariables

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Not A Bug
    • 3.13.0
    • None
    • PMD
    • None
    • macOS Catalina 10.15.7, OpenJDK 11, Maven 3.6.3

    Description

      I am getting following error when running 

      mvn clean install
      [ERROR] Failed to execute goal org.apache.maven.plugins:maven-pmd-plugin:3.13.0:pmd (default-cli) on project pmd-issue: Execution default-cli of goal org.apache.maven.plugins:maven-pmd-plugin:3.13.0:pmd failed: Unable to find referenced rule AvoidReassigningCatchVariables; perhaps the rule name is mispelled? -> [Help 1]

      The rule I want to add (https://pmd.github.io/latest/pmd_rules_java_bestpractices.html#avoidreassigningcatchvariables) was added in PMD 6.27.0 and Maven PMD Plugin is using 6.29.0 version of PMD.

      For this bug I have created very simple maven project with empty main java class and one ruleset  "AvoidReassigningCatchVariables". Code is very simple. If you would prefer source code files as attachment, please let me know.

      src/main/java/com/example/Main.java

      package com.example; 
      public class Main { public static void main(String[] args) { } } 

      src/pmd/checks.xml

      <?xml version="1.0" encoding="UTF-8"?> 
      <ruleset xsi:schemaLocation="http://pmd.sourceforge.net/ruleset/2.0.0 http://pmd.sourceforge.net/ruleset_2_0_0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://pmd.sourceforge.net/ruleset/2.0.0" name="All Java Rules">
      <description>PMD rules for Currency Cloud</description>
      <exclude-pattern>.*Test\.java</exclude-pattern> 
      <rule ref="category/java/bestpractices.xml/AvoidReassigningCatchVariables" /> </ruleset>
      

       

      src/pom.xml

      <?xml version="1.0" encoding="UTF-8"?> 
      <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 
      <modelVersion>4.0.0</modelVersion> 
      <groupId>com.example</groupId>
       <artifactId>pmd-issue</artifactId>
       <version>1.0-SNAPSHOT</version>
       <properties> 
        <maven.compiler.target>11</maven.compiler.target>
        <maven.compiler.source>11</maven.compiler.source>.
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <version.java>11</version.java> 
      </properties> 
      <build> 
      <pluginManagement> 
      <plugins> 
      <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-pmd-plugin</artifactId> 
      <version>3.13.0</version> 
      <configuration> 
      <sourceEncoding>${project.build.sourceEncoding}</sourceEncoding> 
      <minimumTokens>100</minimumTokens> 
      <targetJdk>${version.java}</targetJdk>
       <failOnViolation>true</failOnViolation>
       <skip>false</skip> 
      <rulesets> 
      <ruleset>src/pmd/checks.xml</ruleset>
       </rulesets> </configuration> 
      <executions> 
      <execution>
       <goals> 
      <goal>check</goal>
       </goals>
       <phase>validate</phase>
       </execution> </executions> 
      </plugin> </plugins> </pluginManagement> 
      <resources> 
      <resource> 
      <directory>src/main/pmd</directory> 
      </resource> </resources> </build> </project>

       

       

       

      Attachments

        1. stacktrace-pmd.txt
          8 kB
          Jacek Musial

        Activity

          People

            Unassigned Unassigned
            jacekmusial Jacek Musial
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: