Compare commits
No commits in common. "master" and "1.1.11" have entirely different histories.
9 changed files with 45 additions and 254 deletions
12
.github/workflows/bld.yml
vendored
12
.github/workflows/bld.yml
vendored
|
@ -1,16 +1,14 @@
|
||||||
name: bld-ci
|
name: bld-ci
|
||||||
|
|
||||||
on: [ push, pull_request, workflow_dispatch ]
|
on: [push, pull_request, workflow_dispatch]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build-bld-project:
|
build-bld-project:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
java-version: [ 17, 21, 24 ]
|
java-version: [17, 21, 23]
|
||||||
kotlin-version: [ 1.9.25, 2.0.21, 2.1.20 ]
|
|
||||||
os: [ ubuntu-latest, windows-latest, macos-latest ]
|
|
||||||
|
|
||||||
runs-on: ${{ matrix.os }}
|
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout source repository
|
- name: Checkout source repository
|
||||||
|
@ -28,4 +26,4 @@ jobs:
|
||||||
run: ./bld download
|
run: ./bld download
|
||||||
|
|
||||||
- name: Run tests
|
- name: Run tests
|
||||||
run: ./bld compile test
|
run: ./bld compile test
|
||||||
|
|
4
.idea/libraries/bld.xml
generated
4
.idea/libraries/bld.xml
generated
|
@ -2,12 +2,12 @@
|
||||||
<library name="bld">
|
<library name="bld">
|
||||||
<CLASSES>
|
<CLASSES>
|
||||||
<root url="file://$PROJECT_DIR$/lib/bld" />
|
<root url="file://$PROJECT_DIR$/lib/bld" />
|
||||||
<root url="jar://$USER_HOME$/.bld/dist/bld-2.2.1.jar!/" />
|
<root url="jar://$USER_HOME$/.bld/dist/bld-2.2.0.jar!/" />
|
||||||
</CLASSES>
|
</CLASSES>
|
||||||
<JAVADOC />
|
<JAVADOC />
|
||||||
<SOURCES>
|
<SOURCES>
|
||||||
<root url="file://$PROJECT_DIR$/lib/bld" />
|
<root url="file://$PROJECT_DIR$/lib/bld" />
|
||||||
<root url="jar://$USER_HOME$/.bld/dist/bld-2.2.1-sources.jar!/" />
|
<root url="jar://$USER_HOME$/.bld/dist/bld-2.2.0-sources.jar!/" />
|
||||||
</SOURCES>
|
</SOURCES>
|
||||||
<excluded>
|
<excluded>
|
||||||
<root url="jar://$PROJECT_DIR$/lib/bld/bld-wrapper.jar!/" />
|
<root url="jar://$PROJECT_DIR$/lib/bld/bld-wrapper.jar!/" />
|
||||||
|
|
2
.vscode/settings.json
vendored
2
.vscode/settings.json
vendored
|
@ -9,7 +9,7 @@
|
||||||
],
|
],
|
||||||
"java.configuration.updateBuildConfiguration": "automatic",
|
"java.configuration.updateBuildConfiguration": "automatic",
|
||||||
"java.project.referencedLibraries": [
|
"java.project.referencedLibraries": [
|
||||||
"${HOME}/.bld/dist/bld-2.2.1.jar",
|
"${HOME}/.bld/dist/bld-2.2.0.jar",
|
||||||
"lib/**/*.jar"
|
"lib/**/*.jar"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
14
README.md
14
README.md
|
@ -2,22 +2,14 @@
|
||||||
|
|
||||||
[](https://opensource.org/licenses/Apache-2.0)
|
[](https://opensource.org/licenses/Apache-2.0)
|
||||||
[](https://www.oracle.com/java/technologies/javase/jdk17-archive-downloads.html)
|
[](https://www.oracle.com/java/technologies/javase/jdk17-archive-downloads.html)
|
||||||
[](https://rife2.com/bld)
|
[](https://rife2.com/bld)
|
||||||
[](https://repo.rife2.com/#/releases/com/uwyn/rife2/bld-pmd)
|
[](https://repo.rife2.com/#/releases/com/uwyn/rife2/bld-pmd)
|
||||||
[](https://repo.rife2.com/#/snapshots/com/uwyn/rife2/bld-pmd)
|
[](https://repo.rife2.com/#/snapshots/com/uwyn/rife2/bld-pmd)
|
||||||
[](https://github.com/rife2/bld-pmd/actions/workflows/bld.yml)
|
[](https://github.com/rife2/bld-pmd/actions/workflows/bld.yml)
|
||||||
|
|
||||||
To install the latest version, add the following to the `lib/bld/bld-wrapper.properties` file:
|
To install, please refer to the [extensions documentation](https://github.com/rife2/bld/wiki/Extensions).
|
||||||
|
|
||||||
```properties
|
To check all source code using the [Java Quickstart](https://docs.pmd-code.org/latest/pmd_rules_java.html) configuration, add the following to your build file:
|
||||||
bld.extension-pmd=com.uwyn.rife2:bld-pmd
|
|
||||||
```
|
|
||||||
|
|
||||||
For more information, please refer to the [extensions](https://github.com/rife2/bld/wiki/Extensions) documentation.
|
|
||||||
|
|
||||||
## Check Source with PMD
|
|
||||||
|
|
||||||
To check all source Codecode using the [Java Quickstart](https://docs.pmd-code.org/latest/pmd_rules_java.html) configuration, add the following to your build file:
|
|
||||||
|
|
||||||
```java
|
```java
|
||||||
@BuildCommand(summary = "Checks source code with PMD")
|
@BuildCommand(summary = "Checks source code with PMD")
|
||||||
|
|
Binary file not shown.
|
@ -2,4 +2,4 @@ bld.downloadExtensionJavadoc=false
|
||||||
bld.downloadExtensionSources=true
|
bld.downloadExtensionSources=true
|
||||||
bld.downloadLocation=
|
bld.downloadLocation=
|
||||||
bld.repositories=MAVEN_LOCAL,MAVEN_CENTRAL,RIFE2_SNAPSHOTS,RIFE2_RELEASES
|
bld.repositories=MAVEN_LOCAL,MAVEN_CENTRAL,RIFE2_SNAPSHOTS,RIFE2_RELEASES
|
||||||
bld.version=2.2.1
|
bld.version=2.2.0
|
||||||
|
|
|
@ -31,7 +31,7 @@ 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(1, 2, 3);
|
version = version(1, 1, 11);
|
||||||
|
|
||||||
javaRelease = 17;
|
javaRelease = 17;
|
||||||
|
|
||||||
|
@ -40,15 +40,15 @@ public class PmdOperationBuild extends Project {
|
||||||
|
|
||||||
repositories = List.of(MAVEN_LOCAL, MAVEN_CENTRAL, RIFE2_RELEASES, RIFE2_SNAPSHOTS);
|
repositories = List.of(MAVEN_LOCAL, MAVEN_CENTRAL, RIFE2_RELEASES, RIFE2_SNAPSHOTS);
|
||||||
|
|
||||||
var pmd = version(7, 13, 0);
|
var pmd = version(7, 10, 0);
|
||||||
scope(compile)
|
scope(compile)
|
||||||
.include(dependency("com.uwyn.rife2", "bld", version(2, 2, 1)))
|
.include(dependency("com.uwyn.rife2", "bld", version(2, 2, 0)))
|
||||||
.include(dependency("net.sourceforge.pmd", "pmd-java", pmd));
|
.include(dependency("net.sourceforge.pmd", "pmd-java", pmd));
|
||||||
scope(runtime)
|
scope(runtime)
|
||||||
.include(dependency("org.slf4j", "slf4j-simple", version(2, 0, 17)));
|
.include(dependency("org.slf4j", "slf4j-simple", version(2, 0, 16)));
|
||||||
scope(test)
|
scope(test)
|
||||||
.include(dependency("org.junit.jupiter", "junit-jupiter", version(5, 12, 2)))
|
.include(dependency("org.junit.jupiter", "junit-jupiter", version(5, 11, 4)))
|
||||||
.include(dependency("org.junit.platform", "junit-platform-console-standalone", version(1, 12, 2)))
|
.include(dependency("org.junit.platform", "junit-platform-console-standalone", version(1, 11, 4)))
|
||||||
.include(dependency("org.assertj", "assertj-core", version(3, 27, 3)));
|
.include(dependency("org.assertj", "assertj-core", version(3, 27, 3)));
|
||||||
|
|
||||||
javadocOperation()
|
javadocOperation()
|
||||||
|
|
|
@ -52,7 +52,7 @@ public class PmdOperation extends AbstractOperation<PmdOperation> {
|
||||||
/**
|
/**
|
||||||
* The list of paths to exclude.
|
* The list of paths to exclude.
|
||||||
*/
|
*/
|
||||||
private final Collection<Path> excludes_ = new ArrayList<>();
|
private final List<Path> excludes_ = new ArrayList<>();
|
||||||
/**
|
/**
|
||||||
* The input paths (source) list.
|
* The input paths (source) list.
|
||||||
*/
|
*/
|
||||||
|
@ -142,79 +142,6 @@ public class PmdOperation extends AbstractOperation<PmdOperation> {
|
||||||
*/
|
*/
|
||||||
private int threads_ = 1;
|
private int threads_ = 1;
|
||||||
|
|
||||||
/**
|
|
||||||
* Adds paths to exclude from the analysis.
|
|
||||||
*
|
|
||||||
* @param excludes one or more paths to exclude
|
|
||||||
* @return this operation
|
|
||||||
* @see #excludes(Path...)
|
|
||||||
* @since 1.2.0
|
|
||||||
*/
|
|
||||||
public PmdOperation addExcludes(Path... excludes) {
|
|
||||||
return addExcludes(List.of(excludes));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Adds paths to exclude from the analysis.
|
|
||||||
*
|
|
||||||
* @param excludes paths to exclude
|
|
||||||
* @return this operation
|
|
||||||
* @see #excludes(Collection)
|
|
||||||
* @since 1.2.0
|
|
||||||
*/
|
|
||||||
public PmdOperation addExcludes(Collection<Path> excludes) {
|
|
||||||
excludes_.addAll(excludes);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Adds paths to exclude from the analysis.
|
|
||||||
*
|
|
||||||
* @param excludes one or more paths to exclude
|
|
||||||
* @return this operation
|
|
||||||
* @see #excludesFiles(Collection)
|
|
||||||
* @since 1.2.0
|
|
||||||
*/
|
|
||||||
public PmdOperation addExcludesFiles(Collection<File> excludes) {
|
|
||||||
return addExcludes(excludes.stream().map(File::toPath).toList());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Adds paths to exclude from the analysis.
|
|
||||||
*
|
|
||||||
* @param excludes one or more paths to exclude
|
|
||||||
* @return this operation
|
|
||||||
* @see #excludesFiles(File...)
|
|
||||||
* @since 1.2.0
|
|
||||||
*/
|
|
||||||
public PmdOperation addExcludesFiles(File... excludes) {
|
|
||||||
return addExcludesFiles(List.of(excludes));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Adds paths to exclude from the analysis.
|
|
||||||
*
|
|
||||||
* @param excludes one or more paths to exclude
|
|
||||||
* @return this operation
|
|
||||||
* @see #excludesStrings(Collection)
|
|
||||||
* @since 1.2.0
|
|
||||||
*/
|
|
||||||
public PmdOperation addExcludesStrings(Collection<String> excludes) {
|
|
||||||
return addExcludes(excludes.stream().map(Paths::get).toList());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Adds paths to exclude from the analysis.
|
|
||||||
*
|
|
||||||
* @param excludes one or more paths to exclude
|
|
||||||
* @return this operation
|
|
||||||
* @see #excludesStrings(String...)
|
|
||||||
* @since 1.2.0
|
|
||||||
*/
|
|
||||||
public PmdOperation addExcludesStrings(String... excludes) {
|
|
||||||
return addExcludesStrings(List.of(excludes));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds paths to source files, or directories containing source files to analyze.\
|
* Adds paths to source files, or directories containing source files to analyze.\
|
||||||
*
|
*
|
||||||
|
@ -395,26 +322,23 @@ public class PmdOperation extends AbstractOperation<PmdOperation> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets paths to exclude from the analysis.
|
* Adds paths to exclude from the analysis.
|
||||||
*
|
*
|
||||||
* @param excludes one or more paths to exclude
|
* @param excludes one or more paths to exclude
|
||||||
* @return this operation
|
* @return this operation
|
||||||
* @see #addExcludes(Path...)
|
|
||||||
*/
|
*/
|
||||||
public PmdOperation excludes(Path... excludes) {
|
public PmdOperation excludes(Path... excludes) {
|
||||||
excludes(List.of(excludes));
|
excludes_.addAll(List.of(excludes));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets paths to exclude from the analysis.
|
* Adds paths to exclude from the analysis.
|
||||||
*
|
*
|
||||||
* @param excludes paths to exclude
|
* @param excludes paths to exclude
|
||||||
* @return this operation
|
* @return this operation
|
||||||
* @see #addExcludes(Collection)
|
|
||||||
*/
|
*/
|
||||||
public PmdOperation excludes(Collection<Path> excludes) {
|
public PmdOperation excludes(Collection<Path> excludes) {
|
||||||
excludes_.clear();
|
|
||||||
excludes_.addAll(excludes);
|
excludes_.addAll(excludes);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
@ -424,60 +348,10 @@ public class PmdOperation extends AbstractOperation<PmdOperation> {
|
||||||
*
|
*
|
||||||
* @return the exclude paths
|
* @return the exclude paths
|
||||||
*/
|
*/
|
||||||
public Collection<Path> excludes() {
|
public List<Path> excludes() {
|
||||||
return excludes_;
|
return excludes_;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets paths to exclude from the analysis.
|
|
||||||
*
|
|
||||||
* @param excludes one or more paths to exclude
|
|
||||||
* @return this operation
|
|
||||||
* @see #excludesFiles(Collection)
|
|
||||||
* @since 1.2.0
|
|
||||||
*/
|
|
||||||
public PmdOperation excludesFiles(Collection<File> excludes) {
|
|
||||||
excludes(excludes.stream().map(File::toPath).toList());
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets paths to exclude from the analysis.
|
|
||||||
*
|
|
||||||
* @param excludes one or more paths to exclude
|
|
||||||
* @return this operation
|
|
||||||
* @see #excludesFiles(File...)
|
|
||||||
* @since 1.2.0
|
|
||||||
*/
|
|
||||||
public PmdOperation excludesFiles(File... excludes) {
|
|
||||||
return excludesFiles(List.of(excludes));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets paths to exclude from the analysis.
|
|
||||||
*
|
|
||||||
* @param excludes one or more paths to exclude
|
|
||||||
* @return this operation
|
|
||||||
* @see #excludesStrings(Collection)
|
|
||||||
* @since 1.2.0
|
|
||||||
*/
|
|
||||||
public PmdOperation excludesStrings(Collection<String> excludes) {
|
|
||||||
excludes(excludes.stream().map(Paths::get).toList());
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets paths to exclude from the analysis.
|
|
||||||
*
|
|
||||||
* @param excludes one or more paths to exclude
|
|
||||||
* @return this operation
|
|
||||||
* @see #excludesStrings(String...)
|
|
||||||
* @since 1.2.0
|
|
||||||
*/
|
|
||||||
public PmdOperation excludesStrings(String... excludes) {
|
|
||||||
return excludesStrings(List.of(excludes));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Performs the PMD code analysis operation.
|
* Performs the PMD code analysis operation.
|
||||||
*/
|
*/
|
||||||
|
@ -645,7 +519,7 @@ public class PmdOperation extends AbstractOperation<PmdOperation> {
|
||||||
|
|
||||||
// setExcludes
|
// setExcludes
|
||||||
if (!excludes_.isEmpty()) {
|
if (!excludes_.isEmpty()) {
|
||||||
config.setExcludes(excludes_.stream().toList());
|
config.setExcludes(excludes_);
|
||||||
}
|
}
|
||||||
|
|
||||||
// setFailOnError
|
// setFailOnError
|
||||||
|
@ -782,7 +656,7 @@ public class PmdOperation extends AbstractOperation<PmdOperation> {
|
||||||
*
|
*
|
||||||
* @param inputPath a collection of input paths
|
* @param inputPath a collection of input paths
|
||||||
* @return this operation
|
* @return this operation
|
||||||
* @see #addInputPathsFiles(Collection)
|
* @see #addInputPathsFiles(Collection) )
|
||||||
*/
|
*/
|
||||||
public PmdOperation inputPathsFiles(Collection<File> inputPath) {
|
public PmdOperation inputPathsFiles(Collection<File> inputPath) {
|
||||||
return inputPaths(inputPath.stream().map(File::toPath).toList());
|
return inputPaths(inputPath.stream().map(File::toPath).toList());
|
||||||
|
|
|
@ -47,7 +47,6 @@ import static org.assertj.core.api.Assertions.assertThatCode;
|
||||||
* @since 1.0
|
* @since 1.0
|
||||||
*/
|
*/
|
||||||
class PmdOperationTest {
|
class PmdOperationTest {
|
||||||
static final String BAR = "bar";
|
|
||||||
static final String CATEGORY_FOO = "category/foo.xml";
|
static final String CATEGORY_FOO = "category/foo.xml";
|
||||||
static final Path CODE_STYLE_SAMPLE = Path.of("src/test/resources/java/CodeStyle.java");
|
static final Path CODE_STYLE_SAMPLE = Path.of("src/test/resources/java/CodeStyle.java");
|
||||||
static final String CODE_STYLE_XML = "category/java/codestyle.xml";
|
static final String CODE_STYLE_XML = "category/java/codestyle.xml";
|
||||||
|
@ -56,11 +55,6 @@ class PmdOperationTest {
|
||||||
static final String DOCUMENTATION_XML = "category/java/documentation.xml";
|
static final String DOCUMENTATION_XML = "category/java/documentation.xml";
|
||||||
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 ERROR_PRONE_XML = "category/java/errorprone.xml";
|
static final String ERROR_PRONE_XML = "category/java/errorprone.xml";
|
||||||
static final File FILE_BAR = new File(BAR);
|
|
||||||
static final String FOO = "foo";
|
|
||||||
static final File FILE_FOO = new File(FOO);
|
|
||||||
static final Path PATH_BAR = Path.of(BAR);
|
|
||||||
static final Path PATH_FOO = Path.of(FOO);
|
|
||||||
static final String PERFORMANCE_XML = "category/java/performance.xml";
|
static final String PERFORMANCE_XML = "category/java/performance.xml";
|
||||||
static final String SECURITY_XML = "category/java/security.xml";
|
static final String SECURITY_XML = "category/java/security.xml";
|
||||||
static final String TEST = "test";
|
static final String TEST = "test";
|
||||||
|
@ -73,39 +67,6 @@ class PmdOperationTest {
|
||||||
.reportFile(Paths.get("build", COMMAND_NAME, "pmd-test-report.txt"));
|
.reportFile(Paths.get("build", COMMAND_NAME, "pmd-test-report.txt"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
void testAddExcludes() {
|
|
||||||
var pmd = newPmdOperation().ruleSets(CATEGORY_FOO).addExcludes(PATH_FOO);
|
|
||||||
var config = pmd.initConfiguration(COMMAND_NAME);
|
|
||||||
assertThat(config.getExcludes()).containsExactly(PATH_FOO);
|
|
||||||
|
|
||||||
pmd = pmd.addExcludes(PATH_BAR);
|
|
||||||
config = pmd.initConfiguration(COMMAND_NAME);
|
|
||||||
assertThat(config.getExcludes()).containsExactly(PATH_FOO, PATH_BAR);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
void testAddExcludesFiles() {
|
|
||||||
var pmd = newPmdOperation().ruleSets(CATEGORY_FOO).addExcludesFiles(FILE_FOO);
|
|
||||||
var config = pmd.initConfiguration(COMMAND_NAME);
|
|
||||||
assertThat(config.getExcludes()).containsExactly(FILE_FOO.toPath());
|
|
||||||
|
|
||||||
pmd = pmd.addExcludesFiles(FILE_BAR);
|
|
||||||
config = pmd.initConfiguration(COMMAND_NAME);
|
|
||||||
assertThat(config.getExcludes()).containsExactly(FILE_FOO.toPath(), FILE_BAR.toPath());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
void testAddExcludesStrings() {
|
|
||||||
var pmd = newPmdOperation().ruleSets(CATEGORY_FOO).addExcludesStrings(FOO);
|
|
||||||
var config = pmd.initConfiguration(COMMAND_NAME);
|
|
||||||
assertThat(config.getExcludes()).containsExactly(PATH_FOO);
|
|
||||||
|
|
||||||
pmd = pmd.addExcludesStrings(BAR);
|
|
||||||
config = pmd.initConfiguration(COMMAND_NAME);
|
|
||||||
assertThat(config.getExcludes()).containsExactly(PATH_FOO, PATH_BAR);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testAddInputPaths() throws ExitStatusException {
|
void testAddInputPaths() throws ExitStatusException {
|
||||||
var project = new BaseProject();
|
var project = new BaseProject();
|
||||||
|
@ -207,55 +168,20 @@ class PmdOperationTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testExcludes() {
|
void testExcludes() {
|
||||||
|
var foo = Path.of("foo/bar");
|
||||||
|
var bar = Path.of("bar/foo");
|
||||||
var foz = Path.of("foz/baz");
|
var foz = Path.of("foz/baz");
|
||||||
var baz = Path.of("baz/foz");
|
var baz = Path.of("baz/foz");
|
||||||
|
|
||||||
var pmd = newPmdOperation().ruleSets(CATEGORY_FOO).excludes(PATH_FOO, PATH_BAR);
|
var excludes = List.of(foo, bar);
|
||||||
|
var pmd = newPmdOperation().ruleSets(CATEGORY_FOO).excludes(excludes);
|
||||||
var config = pmd.initConfiguration(COMMAND_NAME);
|
var config = pmd.initConfiguration(COMMAND_NAME);
|
||||||
assertThat(pmd.excludes()).containsExactly(List.of(PATH_FOO, PATH_BAR).toArray(new Path[0]));
|
assertThat(config.getExcludes()).containsExactly(excludes.toArray(new Path[0]));
|
||||||
assertThat(config.getExcludes()).containsExactly(List.of(PATH_FOO, PATH_BAR).toArray(new Path[0]));
|
|
||||||
|
|
||||||
var excludes = List.of(List.of(PATH_FOO, PATH_BAR), List.of(foz, baz));
|
pmd = pmd.excludes(baz, foz);
|
||||||
for (var exclude : excludes) {
|
assertThat(pmd.excludes()).hasSize(4);
|
||||||
pmd = newPmdOperation().ruleSets(CATEGORY_FOO).excludes(exclude);
|
config = pmd.initConfiguration(COMMAND_NAME);
|
||||||
config = pmd.initConfiguration(COMMAND_NAME);
|
assertThat(config.getExcludes()).hasSize(4).contains(bar, foz);
|
||||||
assertThat(config.getExcludes()).containsExactly(exclude.toArray(new Path[0]));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
void testExcludesFiles() {
|
|
||||||
var foz = new File("foz");
|
|
||||||
var baz = new File("baz");
|
|
||||||
|
|
||||||
var pmd = newPmdOperation().ruleSets(CATEGORY_FOO).excludesFiles(FILE_FOO, FILE_BAR);
|
|
||||||
var config = pmd.initConfiguration(COMMAND_NAME);
|
|
||||||
assertThat(config.getExcludes()).containsExactly(FILE_FOO.toPath(), FILE_BAR.toPath());
|
|
||||||
|
|
||||||
var excludes = List.of(List.of(FILE_FOO, FILE_BAR), List.of(foz, baz));
|
|
||||||
for (var exclude : excludes) {
|
|
||||||
pmd = newPmdOperation().ruleSets(CATEGORY_FOO).excludesFiles(exclude);
|
|
||||||
config = pmd.initConfiguration(COMMAND_NAME);
|
|
||||||
assertThat(config.getExcludes()).containsExactly(exclude.stream().map(File::toPath).toArray(Path[]::new));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
void testExcludesStrings() {
|
|
||||||
var foz = "foz";
|
|
||||||
var baz = "baz";
|
|
||||||
|
|
||||||
var pmd = newPmdOperation().ruleSets(CATEGORY_FOO).excludesStrings(FOO, BAR);
|
|
||||||
var config = pmd.initConfiguration(COMMAND_NAME);
|
|
||||||
assertThat(pmd.excludes()).containsExactly(PATH_FOO, PATH_BAR);
|
|
||||||
assertThat(config.getExcludes()).containsExactly(PATH_FOO, PATH_BAR);
|
|
||||||
|
|
||||||
var excludes = List.of(List.of(FOO, BAR), List.of(foz, baz));
|
|
||||||
for (var exclude : excludes) {
|
|
||||||
pmd = newPmdOperation().ruleSets(CATEGORY_FOO).excludesStrings(exclude);
|
|
||||||
config = pmd.initConfiguration(COMMAND_NAME);
|
|
||||||
assertThat(config.getExcludes()).containsExactly(exclude.stream().map(Paths::get).toArray(Path[]::new));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -462,8 +388,8 @@ class PmdOperationTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testPrependAuxClasspath() {
|
void testPrependAuxClasspath() {
|
||||||
var pmd = newPmdOperation().ruleSets(CATEGORY_FOO).prependAuxClasspath(FOO, BAR);
|
var pmd = newPmdOperation().ruleSets(CATEGORY_FOO).prependAuxClasspath("foo", "bar");
|
||||||
assertThat(pmd.prependAuxClasspath()).isEqualTo(FOO + File.pathSeparator + BAR);
|
assertThat(pmd.prependAuxClasspath()).isEqualTo("foo" + File.pathSeparator + "bar");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -474,26 +400,27 @@ class PmdOperationTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testRelativizeRoots() {
|
void testRelativizeRoots() {
|
||||||
|
var foo = Path.of("foo/bar");
|
||||||
|
var bar = Path.of("bar/foo");
|
||||||
var baz = Path.of("baz/foz");
|
var baz = Path.of("baz/foz");
|
||||||
|
|
||||||
var pmd = newPmdOperation().ruleSets(List.of(CATEGORY_FOO)).relativizeRoots(PATH_FOO).
|
var pmd = newPmdOperation().ruleSets(List.of(CATEGORY_FOO)).relativizeRoots(foo).relativizeRoots(bar.toFile())
|
||||||
relativizeRoots(PATH_BAR.toFile()).relativizeRoots(baz.toString())
|
.relativizeRoots(baz.toString()).relativizeRoots(List.of(foo, bar, baz));
|
||||||
.relativizeRoots(List.of(PATH_FOO, PATH_BAR, baz));
|
|
||||||
var config = pmd.initConfiguration(COMMAND_NAME);
|
var config = pmd.initConfiguration(COMMAND_NAME);
|
||||||
assertThat(config.getRelativizeRoots()).isEqualTo(pmd.relativizeRoots())
|
assertThat(config.getRelativizeRoots()).isEqualTo(pmd.relativizeRoots())
|
||||||
.containsExactly(PATH_FOO, PATH_BAR, baz, PATH_FOO, PATH_BAR, baz);
|
.containsExactly(foo, bar, baz, foo, bar, baz);
|
||||||
|
|
||||||
pmd = newPmdOperation().ruleSets(List.of(CATEGORY_FOO))
|
pmd = newPmdOperation().ruleSets(List.of(CATEGORY_FOO))
|
||||||
.relativizeRootsFiles(List.of(PATH_FOO.toFile(), PATH_BAR.toFile(), baz.toFile()));
|
.relativizeRootsFiles(List.of(foo.toFile(), bar.toFile(), baz.toFile()));
|
||||||
config = pmd.initConfiguration(COMMAND_NAME);
|
config = pmd.initConfiguration(COMMAND_NAME);
|
||||||
assertThat(config.getRelativizeRoots()).as("List(File...)").isEqualTo(pmd.relativizeRoots())
|
assertThat(config.getRelativizeRoots()).as("List(File...)").isEqualTo(pmd.relativizeRoots())
|
||||||
.containsExactly(PATH_FOO, PATH_BAR, baz);
|
.containsExactly(foo, bar, baz);
|
||||||
|
|
||||||
pmd = newPmdOperation().ruleSets(List.of(CATEGORY_FOO))
|
pmd = newPmdOperation().ruleSets(List.of(CATEGORY_FOO))
|
||||||
.relativizeRootsStrings(List.of(PATH_FOO.toString(), PATH_BAR.toString(), baz.toString()));
|
.relativizeRootsStrings(List.of(foo.toString(), bar.toString(), baz.toString()));
|
||||||
config = pmd.initConfiguration(COMMAND_NAME);
|
config = pmd.initConfiguration(COMMAND_NAME);
|
||||||
assertThat(config.getRelativizeRoots()).as("List(String....)").isEqualTo(pmd.relativizeRoots())
|
assertThat(config.getRelativizeRoots()).as("List(String....)").isEqualTo(pmd.relativizeRoots())
|
||||||
.containsExactly(PATH_FOO, PATH_BAR, baz);
|
.containsExactly(foo, bar, baz);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue