Compare commits

...

3 Commits

Author SHA1 Message Date
Andreas Dangel
c49d3d61a9 Release pmd-compat6:7.0.0-rc4+with-pr4749 [skip ci]
Refs #4749
2024-02-02 15:04:51 +01:00
Andreas Dangel
c1140fd3b8 Fix test
(cherry picked from commit dcdab9d792ddd68a341a2e7ffde4dd207f8d665f)
2024-02-02 15:03:17 +01:00
Andreas Bergander
6032236bb0 Fix NoSuchMethodError on processing errors in pmd-compat6
(cherry picked from commit f73d75d5a363f9c09f3880948944a2028b52a6f0)
2024-02-02 15:03:05 +01:00
5 changed files with 32 additions and 4 deletions

View File

@ -11,7 +11,7 @@
</parent>
<artifactId>pmd-compat6</artifactId>
<version>7.0.0-rc4</version>
<version>7.0.0-rc4+with-pr4749</version>
<name>PMD Compatibility Classes for PMD6</name>
<properties>
@ -21,7 +21,7 @@
</properties>
<scm>
<tag>pmd_releases/7.0.0-rc4-pmd-compat6</tag>
<tag>pmd_releases/7.0.0-rc4-pmd-compat6+with-pr4749</tag>
</scm>
<dependencies>

View File

@ -0,0 +1,16 @@
<ruleset xmlns="http://pmd.sourceforge.net/ruleset/2.0.0" name="Exception throwing ruleset">
<description/>
<rule name="ExceptionThrowingRule"
language="java"
class="net.sourceforge.pmd.lang.rule.XPathRule">
<description>Use this rule to produce a processing error.</description>
<priority>3</priority>
<properties>
<property name="xpath">
<value><![CDATA[
error()
]]></value></property>
</properties>
</rule>
</ruleset>

View File

@ -30,8 +30,12 @@
</executions>
<configuration>
<printFailingErrors>true</printFailingErrors>
<skipPmdError>false</skipPmdError>
<skipPmdError>true</skipPmdError> <!-- we want to capture processing errors -->
<minimumTokens>5</minimumTokens>
<rulesets>
<ruleset>/rulesets/java/maven-pmd-plugin-default.xml</ruleset>
<ruleset>${project.basedir}/exception_ruleset.xml</ruleset>
</rulesets>
</configuration>
<dependencies>
<dependency>

View File

@ -29,10 +29,13 @@ String pmdXml = readFile(pmdXmlReport);
if (!pmdXml.contains("<violation beginline=\"5\" endline=\"5\" begincolumn=\"16\" endcolumn=\"37\" rule=\"UnusedLocalVariable\" ruleset=\"Best Practices\" package=\"org.example\" class=\"Main\" method=\"main\" variable=\"thisIsAUnusedLocalVar\"")) {
throw new RuntimeException("Expected violation has not been reported");
}
File mainFile = new File("pmd-for-java/src/main/java/org/example/Main.java");
File mainFile = new File(basedir, "src/main/java/org/example/Main.java");
if (!pmdXml.contains(mainFile + "\">")) {
throw new RuntimeException("Expected violation has not been reported");
}
if (!pmdXml.contains("<error filename=\"" + mainFile.getAbsolutePath()) || !pmdXml.contains(mainFile + "\" msg=\"PmdXPathException")) {
throw new RuntimeException("Processing error has not been reported");
}
File pmdCsvReport = new File(basedir, "target/pmd.csv");
if (!pmdCsvReport.exists()) {

View File

@ -143,6 +143,11 @@ public final class Report {
public Throwable getError() {
return error;
}
// ------------------- compat extensions --------------------
public String getFile() {
return file.getAbsolutePath();
}
}
/**