Minor cleanups
This commit is contained in:
parent
176929cd29
commit
47c0b14ce9
2 changed files with 26 additions and 28 deletions
|
@ -560,7 +560,7 @@ public class PmdOperation extends AbstractOperation<PmdOperation> {
|
|||
*
|
||||
* @param inputPath a collection of input paths
|
||||
* @return this operation
|
||||
* @see #addInputPaths(Path...)
|
||||
* @see #addInputPaths(Collection)
|
||||
*/
|
||||
public PmdOperation inputPaths(Collection<Path> inputPath) {
|
||||
inputPaths_.clear();
|
||||
|
@ -584,7 +584,7 @@ public class PmdOperation extends AbstractOperation<PmdOperation> {
|
|||
*
|
||||
* @param inputPath a collection of input paths
|
||||
* @return this operation
|
||||
* @see #addInputPaths(File...)
|
||||
* @see #addInputPathsFiles(Collection) )
|
||||
*/
|
||||
public PmdOperation inputPathsFiles(Collection<File> inputPath) {
|
||||
return inputPaths(inputPath.stream().map(File::toPath).toList());
|
||||
|
@ -597,7 +597,7 @@ public class PmdOperation extends AbstractOperation<PmdOperation> {
|
|||
*
|
||||
* @param inputPath a collection of input paths
|
||||
* @return this operation
|
||||
* @see #addInputPaths(String...)
|
||||
* @see #addInputPathsStrings(Collection)
|
||||
*/
|
||||
public PmdOperation inputPathsStrings(Collection<String> inputPath) {
|
||||
return inputPaths(inputPath.stream().map(Paths::get).toList());
|
||||
|
@ -804,8 +804,7 @@ public class PmdOperation extends AbstractOperation<PmdOperation> {
|
|||
* @return this operation
|
||||
*/
|
||||
public PmdOperation reportFile(File reportFile) {
|
||||
reportFile_ = reportFile.toPath();
|
||||
return this;
|
||||
return reportFile(reportFile.toPath());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -815,8 +814,7 @@ public class PmdOperation extends AbstractOperation<PmdOperation> {
|
|||
* @return this operation
|
||||
*/
|
||||
public PmdOperation reportFile(String reportFile) {
|
||||
reportFile_ = Paths.get(reportFile);
|
||||
return this;
|
||||
return reportFile(Paths.get(reportFile));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -871,9 +869,7 @@ public class PmdOperation extends AbstractOperation<PmdOperation> {
|
|||
* @see #addRuleSet(String...)
|
||||
*/
|
||||
public PmdOperation ruleSets(String... ruleSet) {
|
||||
ruleSets_.clear();
|
||||
ruleSets_.addAll(List.of(ruleSet));
|
||||
return this;
|
||||
return ruleSets(List.of(ruleSet));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -76,40 +76,42 @@ class PmdOperationTest {
|
|||
|
||||
var err = pmd.performPmdAnalysis(TEST, pmd.initConfiguration(COMMAND_NAME));
|
||||
|
||||
pmd.inputPaths().clear();
|
||||
pmd.addInputPaths(project.srcMainDirectory());
|
||||
|
||||
assertThat(pmd.inputPaths()).as("main").containsExactly(project.srcMainDirectory().toPath());
|
||||
|
||||
pmd.inputPaths().clear();
|
||||
pmd = pmd.addInputPaths(project.srcMainDirectory(), project.srcTestDirectory());
|
||||
|
||||
assertThat(pmd.inputPaths()).as("main, test").containsExactly(project.srcMainDirectory().toPath(),
|
||||
assertThat(pmd.inputPaths()).as("File...").containsExactly(project.srcMainDirectory().toPath(),
|
||||
project.srcTestDirectory().toPath());
|
||||
|
||||
pmd.inputPaths().clear();
|
||||
pmd = pmd.addInputPathsFiles(List.of(project.srcMainDirectory(), project.srcTestDirectory()));
|
||||
|
||||
assertThat(pmd.inputPaths()).as("PathsFiles(main, test)")
|
||||
assertThat(pmd.inputPaths()).as("List(File...)")
|
||||
.containsExactly(project.srcMainDirectory().toPath(), project.srcTestDirectory().toPath());
|
||||
|
||||
pmd.inputPaths().clear();
|
||||
pmd = pmd.addInputPaths(project.srcMainDirectory().getAbsolutePath(),
|
||||
project.srcTestDirectory().getAbsolutePath());
|
||||
|
||||
assertThat(pmd.inputPaths()).as("String...")
|
||||
.containsExactly(project.srcMainDirectory().toPath(), project.srcTestDirectory().toPath());
|
||||
|
||||
pmd.inputPaths().clear();
|
||||
pmd = pmd.addInputPathsStrings(
|
||||
List.of(project.srcMainDirectory().getAbsolutePath(), project.srcTestDirectory().getAbsolutePath()));
|
||||
|
||||
assertThat(pmd.inputPaths()).as("PathsStrings(main, test)")
|
||||
assertThat(pmd.inputPaths()).as("List(String...)")
|
||||
.containsExactly(project.srcMainDirectory().toPath(), project.srcTestDirectory().toPath());
|
||||
|
||||
pmd.inputPaths().clear();
|
||||
pmd = pmd.addInputPaths(project.srcMainDirectory().toPath(), project.srcTestDirectory().toPath());
|
||||
|
||||
assertThat(pmd.inputPaths()).as("toPath(main, test)")
|
||||
assertThat(pmd.inputPaths()).as("Path...")
|
||||
.containsExactly(project.srcMainDirectory().toPath(), project.srcTestDirectory().toPath());
|
||||
|
||||
pmd.inputPaths().clear();
|
||||
pmd = pmd.addInputPaths(List.of(project.srcMainDirectory().toPath(), project.srcTestDirectory().toPath()));
|
||||
|
||||
assertThat(pmd.inputPaths()).as("List(main, test)")
|
||||
assertThat(pmd.inputPaths()).as("List(Path)")
|
||||
.containsExactly(project.srcMainDirectory().toPath(), project.srcTestDirectory().toPath());
|
||||
|
||||
assertThat(pmd.performPmdAnalysis(TEST, pmd.initConfiguration(COMMAND_NAME)))
|
||||
|
@ -234,31 +236,31 @@ class PmdOperationTest {
|
|||
var pmd = newPmdOperation()
|
||||
.ruleSets(PmdOperation.RULE_SET_DEFAULT, CODE_STYLE_XML)
|
||||
.inputPaths(ERROR_PRONE_SAMPLE, CODE_STYLE_SAMPLE);
|
||||
assertThat(pmd.inputPaths()).as("paths").containsExactly(ERROR_PRONE_SAMPLE, CODE_STYLE_SAMPLE);
|
||||
assertThat(pmd.inputPaths()).as("Path....").containsExactly(ERROR_PRONE_SAMPLE, CODE_STYLE_SAMPLE);
|
||||
assertThat(pmd.performPmdAnalysis(TEST, pmd.initConfiguration(COMMAND_NAME))).isGreaterThan(0);
|
||||
|
||||
pmd = newPmdOperation()
|
||||
.ruleSets(PmdOperation.RULE_SET_DEFAULT, CODE_STYLE_XML)
|
||||
.inputPaths(ERROR_PRONE_SAMPLE.toFile(), CODE_STYLE_SAMPLE.toFile());
|
||||
assertThat(pmd.inputPaths()).as("toFile()").containsExactly(ERROR_PRONE_SAMPLE, CODE_STYLE_SAMPLE);
|
||||
assertThat(pmd.inputPaths()).as("File...").containsExactly(ERROR_PRONE_SAMPLE, CODE_STYLE_SAMPLE);
|
||||
assertThat(pmd.performPmdAnalysis(TEST, pmd.initConfiguration(COMMAND_NAME))).isGreaterThan(0);
|
||||
|
||||
pmd = newPmdOperation()
|
||||
.ruleSets(PmdOperation.RULE_SET_DEFAULT, CODE_STYLE_XML)
|
||||
.inputPaths(ERROR_PRONE_SAMPLE.toString(), CODE_STYLE_SAMPLE.toString());
|
||||
assertThat(pmd.inputPaths()).as("toString").containsExactly(ERROR_PRONE_SAMPLE, CODE_STYLE_SAMPLE);
|
||||
assertThat(pmd.inputPaths()).as("String...").containsExactly(ERROR_PRONE_SAMPLE, CODE_STYLE_SAMPLE);
|
||||
assertThat(pmd.performPmdAnalysis(TEST, pmd.initConfiguration(COMMAND_NAME))).isGreaterThan(0);
|
||||
|
||||
pmd = newPmdOperation()
|
||||
.ruleSets(PmdOperation.RULE_SET_DEFAULT, CODE_STYLE_XML)
|
||||
.inputPathsFiles(List.of(ERROR_PRONE_SAMPLE.toFile(), CODE_STYLE_SAMPLE.toFile()));
|
||||
assertThat(pmd.inputPaths()).as("PathsFiles").containsExactly(ERROR_PRONE_SAMPLE, CODE_STYLE_SAMPLE);
|
||||
assertThat(pmd.inputPaths()).as("List(Path...)").containsExactly(ERROR_PRONE_SAMPLE, CODE_STYLE_SAMPLE);
|
||||
assertThat(pmd.performPmdAnalysis(TEST, pmd.initConfiguration(COMMAND_NAME))).isGreaterThan(0);
|
||||
|
||||
pmd = newPmdOperation()
|
||||
.ruleSets(PmdOperation.RULE_SET_DEFAULT, CODE_STYLE_XML)
|
||||
.inputPathsStrings(List.of(ERROR_PRONE_SAMPLE.toString(), CODE_STYLE_SAMPLE.toString()));
|
||||
assertThat(pmd.inputPaths()).as("PathsStrings").containsExactly(ERROR_PRONE_SAMPLE, CODE_STYLE_SAMPLE);
|
||||
assertThat(pmd.inputPaths()).as("List(String...)").containsExactly(ERROR_PRONE_SAMPLE, CODE_STYLE_SAMPLE);
|
||||
assertThat(pmd.performPmdAnalysis(TEST, pmd.initConfiguration(COMMAND_NAME))).isGreaterThan(0);
|
||||
}
|
||||
|
||||
|
@ -347,7 +349,7 @@ class PmdOperationTest {
|
|||
var pmd = newPmdOperation()
|
||||
.forceLanguageVersion(language.getLatestVersion())
|
||||
.defaultLanguageVersions(language.getVersions())
|
||||
.languageVersions(language.getVersion("22"))
|
||||
.languageVersions(language.getDefaultVersion())
|
||||
.ruleSets(PmdOperation.RULE_SET_DEFAULT);
|
||||
assertThat(pmd.languageVersions()).contains(language.getDefaultVersion());
|
||||
assertThat(pmd.performPmdAnalysis(TEST, pmd.initConfiguration(COMMAND_NAME))).isGreaterThan(0);
|
||||
|
@ -386,13 +388,13 @@ class PmdOperationTest {
|
|||
pmd = newPmdOperation().ruleSets(List.of(CATEGORY_FOO))
|
||||
.relativizeRootsFiles(List.of(foo.toFile(), bar.toFile(), baz.toFile()));
|
||||
config = pmd.initConfiguration(COMMAND_NAME);
|
||||
assertThat(config.getRelativizeRoots()).as("toFile").isEqualTo(pmd.relativizeRoots());
|
||||
assertThat(config.getRelativizeRoots()).as("List(File...)").isEqualTo(pmd.relativizeRoots());
|
||||
assertThat(config.getRelativizeRoots()).containsExactly(foo, bar, baz);
|
||||
|
||||
pmd = newPmdOperation().ruleSets(List.of(CATEGORY_FOO))
|
||||
.relativizeRootsStrings(List.of(foo.toString(), bar.toString(), baz.toString()));
|
||||
config = pmd.initConfiguration(COMMAND_NAME);
|
||||
assertThat(config.getRelativizeRoots()).as("toString").isEqualTo(pmd.relativizeRoots());
|
||||
assertThat(config.getRelativizeRoots()).as("List(String....)").isEqualTo(pmd.relativizeRoots());
|
||||
assertThat(config.getRelativizeRoots()).containsExactly(foo, bar, baz);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue