diff --git a/README.md b/README.md index f29823b..371cd0d 100755 --- a/README.md +++ b/README.md @@ -25,8 +25,6 @@ public void checkstyle() throws Exception { ./bld checkstyle ``` -- [View Examples](https://github.com/rife2/bld-checkstyle/blob/master/examples/src/bld/java/com/example/) - Please check the [CheckstyleOperation documentation](https://rife2.github.io/bld-checkstyle/rife/bld/extension/CheckstyleOperation.html#method-summary) for all available configuration options. ### Checkstyle Dependency diff --git a/examples/.idea/misc.xml b/examples/.idea/misc.xml index 542659b..11f86d2 100644 --- a/examples/.idea/misc.xml +++ b/examples/.idea/misc.xml @@ -1,8 +1,5 @@ - - diff --git a/src/main/java/rife/bld/extension/CheckstyleOperation.java b/src/main/java/rife/bld/extension/CheckstyleOperation.java index 34e6e72..b36c7bb 100644 --- a/src/main/java/rife/bld/extension/CheckstyleOperation.java +++ b/src/main/java/rife/bld/extension/CheckstyleOperation.java @@ -79,8 +79,6 @@ public class CheckstyleOperation extends AbstractProcessOperation path) { - for (var p : path) { - optionsWithArg.put("-e", p); - } - return this; - } - /** * Directory/file pattern to exclude from CheckStyle. Multiple excludes are allowed. */ @@ -234,24 +219,12 @@ public class CheckstyleOperation extends AbstractProcessOperation dir) { - sourceDirs.addAll(dir); - return this; - } - /** * Sets the length of the tab character. Used only with the {@link #lineColumn(String) lineColum} option. * Default value is {@code 8}. diff --git a/src/test/java/rife/bld/extension/CheckstyleOperationTest.java b/src/test/java/rife/bld/extension/CheckstyleOperationTest.java index edd223f..650dc1f 100644 --- a/src/test/java/rife/bld/extension/CheckstyleOperationTest.java +++ b/src/test/java/rife/bld/extension/CheckstyleOperationTest.java @@ -24,17 +24,13 @@ import rife.bld.operations.exceptions.ExitStatusException; import java.io.File; import java.io.IOException; -import java.util.List; import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatCode; class CheckstyleOperationTest { - private static final String ADD = "add"; private static final String BAR = "bar"; private static final String FOO = "foo"; - private static final String REMOVE = "remove"; @Test void branchMatchingXpath() { @@ -51,17 +47,15 @@ class CheckstyleOperationTest { @Test void debug() { var op = new CheckstyleOperation().fromProject(new Project()).debug(true); - assertThat(op.options.contains("-d")).as(ADD).isTrue(); + assertThat(op.options.contains("-d")).as("add").isTrue(); op = op.debug(false); - assertThat(op.options.contains("-d")).as(REMOVE).isFalse(); + assertThat(op.options.contains("-d")).as("remove").isFalse(); } @Test void exclude() { var op = new CheckstyleOperation().fromProject(new Project()).exclude(FOO); assertThat(op.optionsWithArg.get("-e")).isEqualTo(FOO); - op = new CheckstyleOperation().fromProject(new Project()).exclude(List.of(FOO)); - assertThat(op.optionsWithArg.get("-e")).as("as list").isEqualTo(FOO); } @Test @@ -72,7 +66,7 @@ class CheckstyleOperationTest { @Test void execute() throws IOException, ExitStatusException, InterruptedException { - var tmpFile = File.createTempFile("checkstyle-google", ".txt"); + var tmpFile = File.createTempFile("checkstyle", ".txt"); tmpFile.deleteOnExit(); var op = new CheckstyleOperation() .fromProject(new WebProject()) @@ -96,32 +90,19 @@ class CheckstyleOperationTest { .startsWith("java -cp ") .endsWith( "com.puppycrawl.tools.checkstyle.Main " + - "-d -E " + - "-p config/checkstyle.properties " + - "-b xpath " + - "-c config/checkstyle.xml " + - "src/main/java src/test/java"); + "-d -E " + + "-p config/checkstyle.properties " + + "-b xpath " + + "-c config/checkstyle.xml " + + "src/main/java src/test/java"); } @Test void executeIgnoredModules() { var op = new CheckstyleOperation().fromProject(new Project()).executeIgnoredModules(true); - assertThat(op.options.contains("-E")).as(ADD).isTrue(); + assertThat(op.options.contains("-E")).as("add").isTrue(); op = op.executeIgnoredModules(false); - assertThat(op.options.contains("-E")).as(REMOVE).isFalse(); - } - - @Test - void executeSunChecks() throws IOException { - var tmpFile = File.createTempFile("checkstyle-sun", ".txt"); - tmpFile.deleteOnExit(); - var op = new CheckstyleOperation() - .fromProject(new WebProject()) - .sourceDir(List.of("src/main/java", "src/test/java")) - .configurationFile("src/test/resources/sun_checks.xml") - .output(tmpFile.getAbsolutePath()); - assertThatCode(op::execute).isInstanceOf(ExitStatusException.class); - assertThat(tmpFile).exists(); + assertThat(op.options.contains("-E")).as("remove").isFalse(); } @Test @@ -133,17 +114,17 @@ class CheckstyleOperationTest { @Test void generateXpathSuppression() { var op = new CheckstyleOperation().fromProject(new Project()).generateXpathSuppression(true); - assertThat(op.options.contains("-g")).as(ADD).isTrue(); + assertThat(op.options.contains("-g")).as("add").isTrue(); op = op.generateXpathSuppression(false); - assertThat(op.options.contains("-g")).as(REMOVE).isFalse(); + assertThat(op.options.contains("-g")).as("remove").isFalse(); } @Test void javadocTree() { var op = new CheckstyleOperation().fromProject(new Project()).javadocTree(true); - assertThat(op.options.contains("-j")).as(ADD).isTrue(); + assertThat(op.options.contains("-j")).as("add").isTrue(); op = op.javadocTree(false); - assertThat(op.options.contains("-j")).as(REMOVE).isFalse(); + assertThat(op.options.contains("-j")).as("remove").isFalse(); } @Test @@ -181,24 +162,24 @@ class CheckstyleOperationTest { @Test void tree() { var op = new CheckstyleOperation().fromProject(new Project()).tree(true); - assertThat(op.options.contains("-t")).as(ADD).isTrue(); + assertThat(op.options.contains("-t")).as("add").isTrue(); op = op.tree(false); - assertThat(op.options.contains("-t")).as(REMOVE).isFalse(); + assertThat(op.options.contains("-t")).as("remove").isFalse(); } @Test void treeWithComments() { var op = new CheckstyleOperation().fromProject(new Project()).treeWithComments(true); - assertThat(op.options.contains("-T")).as(ADD).isTrue(); + assertThat(op.options.contains("-T")).as("add").isTrue(); op = op.treeWithComments(false); - assertThat(op.options.contains("-T")).as(REMOVE).isFalse(); + assertThat(op.options.contains("-T")).as("remove").isFalse(); } @Test void treeWithJavadoc() { var op = new CheckstyleOperation().fromProject(new Project()).treeWithJavadoc(true); - assertThat(op.options.contains("-J")).as(ADD).isTrue(); + assertThat(op.options.contains("-J")).as("add").isTrue(); op = op.treeWithJavadoc(false); - assertThat(op.options.contains("-J")).as(REMOVE).isFalse(); + assertThat(op.options.contains("-J")).as("remove").isFalse(); } } \ No newline at end of file diff --git a/src/test/resources/sun_checks.xml b/src/test/resources/sun_checks.xml deleted file mode 100644 index 1278ab7..0000000 --- a/src/test/resources/sun_checks.xml +++ /dev/null @@ -1,198 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -