Added support for PMD 7.0.0
This commit is contained in:
parent
9bc04a4cbb
commit
3f33710dba
3 changed files with 24 additions and 7 deletions
|
@ -34,14 +34,14 @@ public class PmdOperationBuild extends Project {
|
||||||
public PmdOperationBuild() {
|
public PmdOperationBuild() {
|
||||||
pkg = "rife.bld.extension";
|
pkg = "rife.bld.extension";
|
||||||
name = "bld-pmd";
|
name = "bld-pmd";
|
||||||
version = version(0, 9, 7);
|
version = version(0, 9, 8);
|
||||||
|
|
||||||
javaRelease = 17;
|
javaRelease = 17;
|
||||||
downloadSources = true;
|
downloadSources = true;
|
||||||
autoDownloadPurge = true;
|
autoDownloadPurge = true;
|
||||||
repositories = List.of(MAVEN_CENTRAL, RIFE2_RELEASES);
|
repositories = List.of(MAVEN_CENTRAL, RIFE2_RELEASES);
|
||||||
|
|
||||||
var pmd = version(7, 0, 0, "rc4");
|
var pmd = version(7, 0, 0);
|
||||||
scope(compile)
|
scope(compile)
|
||||||
.include(dependency("com.uwyn.rife2", "bld", version(1, 9, 0)))
|
.include(dependency("com.uwyn.rife2", "bld", version(1, 9, 0)))
|
||||||
.include(dependency("net.sourceforge.pmd", "pmd-java", pmd));
|
.include(dependency("net.sourceforge.pmd", "pmd-java", pmd));
|
||||||
|
|
|
@ -18,8 +18,8 @@ package rife.bld.extension;
|
||||||
|
|
||||||
import net.sourceforge.pmd.PMDConfiguration;
|
import net.sourceforge.pmd.PMDConfiguration;
|
||||||
import net.sourceforge.pmd.PmdAnalysis;
|
import net.sourceforge.pmd.PmdAnalysis;
|
||||||
import net.sourceforge.pmd.RulePriority;
|
|
||||||
import net.sourceforge.pmd.lang.LanguageVersion;
|
import net.sourceforge.pmd.lang.LanguageVersion;
|
||||||
|
import net.sourceforge.pmd.lang.rule.RulePriority;
|
||||||
import rife.bld.BaseProject;
|
import rife.bld.BaseProject;
|
||||||
import rife.bld.operations.AbstractOperation;
|
import rife.bld.operations.AbstractOperation;
|
||||||
|
|
||||||
|
@ -105,6 +105,10 @@ public class PmdOperation extends AbstractOperation<PmdOperation> {
|
||||||
* The report format.
|
* The report format.
|
||||||
*/
|
*/
|
||||||
String reportFormat_ = "text";
|
String reportFormat_ = "text";
|
||||||
|
/**
|
||||||
|
* The report properties.
|
||||||
|
*/
|
||||||
|
Properties reportProperties_ = null;
|
||||||
/**
|
/**
|
||||||
* The show suppressed flag.
|
* The show suppressed flag.
|
||||||
*/
|
*/
|
||||||
|
@ -359,6 +363,10 @@ public class PmdOperation extends AbstractOperation<PmdOperation> {
|
||||||
config.setInputPathList(inputPaths_);
|
config.setInputPathList(inputPaths_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (reportProperties_ != null) {
|
||||||
|
config.setReportProperties(reportProperties_);
|
||||||
|
}
|
||||||
|
|
||||||
if (inputUri_ != null) {
|
if (inputUri_ != null) {
|
||||||
config.setInputUri(inputUri_);
|
config.setInputUri(inputUri_);
|
||||||
}
|
}
|
||||||
|
@ -367,7 +375,8 @@ public class PmdOperation extends AbstractOperation<PmdOperation> {
|
||||||
|
|
||||||
if (project_ != null) {
|
if (project_ != null) {
|
||||||
config.setReportFile(Objects.requireNonNullElseGet(reportFile_,
|
config.setReportFile(Objects.requireNonNullElseGet(reportFile_,
|
||||||
() -> Paths.get(project_.buildDirectory().getPath(), PMD_DIR, PMD_DIR + "-report." + reportFormat_)));
|
() -> Paths.get(project_.buildDirectory().getPath(),
|
||||||
|
PMD_DIR, PMD_DIR + "-report." + reportFormat_)));
|
||||||
} else {
|
} else {
|
||||||
config.setReportFile(reportFile_);
|
config.setReportFile(reportFile_);
|
||||||
}
|
}
|
||||||
|
@ -430,7 +439,7 @@ public class PmdOperation extends AbstractOperation<PmdOperation> {
|
||||||
v.getRule().getName(),
|
v.getRule().getName(),
|
||||||
v.getRule().getExternalInfoUrl() //TODO bug in PMD?
|
v.getRule().getExternalInfoUrl() //TODO bug in PMD?
|
||||||
.replace("${pmd.website.baseurl}",
|
.replace("${pmd.website.baseurl}",
|
||||||
"https://docs.pmd-code.org/pmd-doc-7.0.0-rc4"),
|
"https://docs.pmd-code.org/latest"),
|
||||||
v.getDescription()});
|
v.getDescription()});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -486,6 +495,14 @@ public class PmdOperation extends AbstractOperation<PmdOperation> {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the Report properties. These are used to create the Renderer.
|
||||||
|
*/
|
||||||
|
public PmdOperation reportProperties(Properties reportProperties) {
|
||||||
|
reportProperties_ = reportProperties;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the rule set path(s), disregarding any previously set paths.
|
* Sets the rule set path(s), disregarding any previously set paths.
|
||||||
* <p>
|
* <p>
|
||||||
|
|
|
@ -43,7 +43,7 @@ class PmdOperationTest {
|
||||||
static final int CODING_STYLE_ERRORS = 13;
|
static final int CODING_STYLE_ERRORS = 13;
|
||||||
static final String COMMAND_NAME = "pmd";
|
static final String COMMAND_NAME = "pmd";
|
||||||
static final String ERROR_PRONE = "category/java/errorprone.xml";
|
static final String ERROR_PRONE = "category/java/errorprone.xml";
|
||||||
static final int ERROR_PRONE_ERRORS = 8;
|
static final int ERROR_PRONE_ERRORS = 6;
|
||||||
static final Path ERROR_PRONE_SAMPLE = Path.of("src/test/resources/java/ErrorProne.java");
|
static final Path ERROR_PRONE_SAMPLE = Path.of("src/test/resources/java/ErrorProne.java");
|
||||||
static final String TEST = "test";
|
static final String TEST = "test";
|
||||||
|
|
||||||
|
@ -126,7 +126,7 @@ class PmdOperationTest {
|
||||||
.as("code style").isEqualTo(CODING_STYLE_ERRORS);
|
.as("code style").isEqualTo(CODING_STYLE_ERRORS);
|
||||||
pmd = pmd.addRuleSet(ERROR_PRONE).addInputPath(ERROR_PRONE_SAMPLE);
|
pmd = pmd.addRuleSet(ERROR_PRONE).addInputPath(ERROR_PRONE_SAMPLE);
|
||||||
assertThat(pmd.performPmdAnalysis(TEST, pmd.initConfiguration(COMMAND_NAME)))
|
assertThat(pmd.performPmdAnalysis(TEST, pmd.initConfiguration(COMMAND_NAME)))
|
||||||
.as("code style + error prone").isEqualTo(34);
|
.as("code style + error prone").isEqualTo(29);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue