+ * Set to: {@code rulesets/java/quickstart.xml}
*/
public static final String RULE_SET_DEFAULT = "rulesets/java/quickstart.xml";
private static final Logger LOGGER = Logger.getLogger(PmdOperation.class.getName());
@@ -48,115 +51,83 @@ public class PmdOperation extends AbstractOperation
@@ -330,6 +345,9 @@ public PmdOperation incrementalAnalysis(boolean incrementalAnalysis) {
/**
* Creates a new initialized configuration.
+ *
+ * @param commandName the command name
+ * @return this operation
*/
public PMDConfiguration initConfiguration(String commandName) {
PMDConfiguration config = new PMDConfiguration();
@@ -344,7 +362,7 @@ public PMDConfiguration initConfiguration(String commandName) {
config.setFailOnViolation(failOnViolation_);
if (languageVersions_ != null) {
- config.setDefaultLanguageVersions(languageVersions_);
+ config.setDefaultLanguageVersions(languageVersions_.stream().toList());
}
if (forcedLanguageVersion_ != null) {
@@ -360,9 +378,8 @@ public PMDConfiguration initConfiguration(String commandName) {
if (inputPaths_.isEmpty()) {
throw new IllegalArgumentException(commandName + ": InputPaths required.");
} else {
- config.setInputPathList(inputPaths_);
+ config.setInputPathList(inputPaths_.stream().toList());
}
-
if (reportProperties_ != null) {
config.setReportProperties(reportProperties_);
}
@@ -381,9 +398,9 @@ public PMDConfiguration initConfiguration(String commandName) {
config.setReportFile(reportFile_);
}
- config.addRelativizeRoots(relativizeRoots_);
+ config.addRelativizeRoots(relativizeRoots_.stream().toList());
config.setReportFormat(reportFormat_);
- config.setRuleSets(ruleSets_);
+ config.setRuleSets(ruleSets_.stream().toList());
config.setShowSuppressedViolations(showSuppressed_);
config.setSourceEncoding(encoding_);
config.setSuppressMarker(suppressedMarker_);
@@ -393,8 +410,11 @@ public PMDConfiguration initConfiguration(String commandName) {
}
/**
- * Sets the to source files, or directories containing source files to analyze.
- * Previously set paths will be disregarded.
+ * Sets paths to source files, or directories containing source files to analyze.
+ *
+ * @param inputPath one or more paths
+ * @return this operation
+ * @see #addInputPaths(Path...)
*/
public PmdOperation inputPaths(Path... inputPath) {
inputPaths_.clear();
@@ -403,18 +423,154 @@ public PmdOperation inputPaths(Path... inputPath) {
}
/**
- * Sets the to source files, or directories containing source files to analyze.
- * Previously set paths will be disregarded.
+ * Sets paths to source files, or directories containing source files to analyze.
+ *
+ * Previous entries are disregarded.
+ *
+ * @param inputPath one or more paths
+ * @return this operation
+ * @see #addInputPaths(File...)
+ */
+ public PmdOperation inputPaths(File... inputPath) {
+ inputPaths_.clear();
+ inputPaths_.addAll(Arrays.stream(inputPath).map(File::toPath).toList());
+ return this;
+ }
+
+ /**
+ * Sets paths to source files, or directories containing source files to analyze.
+ *
+ * Previous entries are disregarded.
+ * @param inputPath one or more paths
+ * @return this operation
+ * @see #addInputPaths(String...)
+ */
+ public PmdOperation inputPaths(String... inputPath) {
+ inputPaths_.clear();
+ inputPaths_.addAll(Arrays.stream(inputPath).map(Paths::get).toList());
+ return this;
+ }
+
+ /**
+ * Sets paths to source files, or directories containing source files to analyze.
+ *
+ * Previous entries are disregarded.
+ * @param inputPath the input paths
+ * @return this operation
+ * @see #addInputPaths(Collection)
*/
public PmdOperation inputPaths(Collection
* The built-in rule set paths are:
*
* The built-in rule set paths are:
*
@@ -518,15 +757,19 @@ public PmdOperation reportProperties(Properties reportProperties) {
*
+ *
+ * @param ruleSet one or more rule set
+ * @return this operation
+ * @see #addRuleSet(String...)
*/
public PmdOperation ruleSets(String... ruleSet) {
ruleSets_.clear();
- ruleSets_.addAll(Arrays.asList(ruleSet));
+ ruleSets_.addAll(List.of(ruleSet));
return this;
}
/**
- * Sets the rule set path(s), disregarding any previously set paths.
+ * Sets new rule set paths, disregarding any previous entries.
*
@@ -540,15 +783,31 @@ public PmdOperation ruleSets(String... ruleSet) {
*
+ *
+ * @param ruleSet one or more rule set
+ * @return this operation
+ * @see #addRuleSet(Collection)
*/
- public PmdOperation ruleSets(Collection