From 81768ff9f947968ca49971c0c73e79fafacf10fc Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Mon, 29 May 2017 11:23:48 +0100 Subject: [PATCH 01/18] builder: CheckstyleWriter: avoid throwing raw exception types Instead of throwing RuntimeException or IOException, throw CheckstyleWriterException or TemplateNotFoundException. --- .../ruleset/builder/CheckstyleWriter.java | 4 +- .../builder/CheckstyleWriterException.java | 39 ++++++++++++++++++ .../builder/TemplateNotFoundException.java | 41 +++++++++++++++++++ .../CheckstyleWriterExceptionTest.java | 19 +++++++++ .../ruleset/builder/CheckstyleWriterTest.java | 24 ++++++----- 5 files changed, 114 insertions(+), 13 deletions(-) create mode 100644 builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/CheckstyleWriterException.java create mode 100644 builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/TemplateNotFoundException.java create mode 100644 builder/src/test/java/net/kemitix/checkstyle/ruleset/builder/CheckstyleWriterExceptionTest.java diff --git a/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/CheckstyleWriter.java b/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/CheckstyleWriter.java index 0619a7d..3e676e7 100644 --- a/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/CheckstyleWriter.java +++ b/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/CheckstyleWriter.java @@ -91,10 +91,10 @@ class CheckstyleWriter implements CommandLineRunner { log.info("Writing xmlFile: {}", xmlFile); Files.write(xmlFile, output, StandardCharsets.UTF_8); } else { - throw new IOException("Missing template: " + checkstyleXmlTemplate.toString()); + throw new TemplateNotFoundException(checkstyleXmlTemplate); } } catch (IOException e) { - throw new RuntimeException(e); + throw new CheckstyleWriterException(e); } } diff --git a/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/CheckstyleWriterException.java b/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/CheckstyleWriterException.java new file mode 100644 index 0000000..641d96e --- /dev/null +++ b/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/CheckstyleWriterException.java @@ -0,0 +1,39 @@ +/** + * The MIT License (MIT) + * + * Copyright (c) 2017 Paul Campbell + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software + * and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies + * or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE + * AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +package net.kemitix.checkstyle.ruleset.builder; + +/** + * Raised when there was an error writing a Checkstyle ruleset. + * + * @author Paul Campbell (pcampbell@kemitix.net) + */ +class CheckstyleWriterException extends RuntimeException { + + /** + * Constructor. + * + * @param cause the cause + */ + CheckstyleWriterException(final Throwable cause) { + super(cause); + } +} diff --git a/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/TemplateNotFoundException.java b/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/TemplateNotFoundException.java new file mode 100644 index 0000000..08d1521 --- /dev/null +++ b/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/TemplateNotFoundException.java @@ -0,0 +1,41 @@ +/** + * The MIT License (MIT) + * + * Copyright (c) 2017 Paul Campbell + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software + * and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies + * or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE + * AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +package net.kemitix.checkstyle.ruleset.builder; + +import java.nio.file.Path; + +/** + * Raised when a rule template is not found. + * + * @author Paul Campbell (pcampbell@kemitix.net) + */ +class TemplateNotFoundException extends RuntimeException { + + /** + * Constructor. + * + * @param template the missing template + */ + TemplateNotFoundException(final Path template) { + super("Missing template: " + template.toString()); + } +} diff --git a/builder/src/test/java/net/kemitix/checkstyle/ruleset/builder/CheckstyleWriterExceptionTest.java b/builder/src/test/java/net/kemitix/checkstyle/ruleset/builder/CheckstyleWriterExceptionTest.java new file mode 100644 index 0000000..ee44130 --- /dev/null +++ b/builder/src/test/java/net/kemitix/checkstyle/ruleset/builder/CheckstyleWriterExceptionTest.java @@ -0,0 +1,19 @@ +package net.kemitix.checkstyle.ruleset.builder; + +import org.junit.Test; + +/** + * Tests for {@link CheckstyleWriterException}. + * + * @author Paul Campbell (pcampbell@kemitix.net) + */ +public class CheckstyleWriterExceptionTest { + + @Test + public void canCreateException() { + //given + //when + //then + } + +} diff --git a/builder/src/test/java/net/kemitix/checkstyle/ruleset/builder/CheckstyleWriterTest.java b/builder/src/test/java/net/kemitix/checkstyle/ruleset/builder/CheckstyleWriterTest.java index da7d873..733908a 100644 --- a/builder/src/test/java/net/kemitix/checkstyle/ruleset/builder/CheckstyleWriterTest.java +++ b/builder/src/test/java/net/kemitix/checkstyle/ruleset/builder/CheckstyleWriterTest.java @@ -2,9 +2,9 @@ package net.kemitix.checkstyle.ruleset.builder; import lombok.val; import me.andrz.builder.map.MapBuilder; +import org.assertj.core.api.ThrowableAssert; import org.junit.Before; import org.junit.Test; -import org.junit.rules.ExpectedException; import org.junit.rules.TemporaryFolder; import org.mockito.MockitoAnnotations; @@ -20,6 +20,7 @@ import java.util.Map; import java.util.UUID; import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; /** * Tests for {@link CheckstyleWriter}. @@ -48,9 +49,6 @@ public class CheckstyleWriterTest { private Path checkstyleTemplate; - @org.junit.Rule - public ExpectedException exception = ExpectedException.none(); - @org.junit.Rule public TemporaryFolder folder = new TemporaryFolder(); @@ -173,10 +171,11 @@ public class CheckstyleWriterTest { public void throwRteIfTemplateNotFound() throws Exception { //given templateProperties.setCheckstyleXml(Paths.get("garbage")); - exception.expect(RuntimeException.class); - exception.expectMessage("Missing template: garbage"); //when - checkstyleWriter.run(); + final ThrowableAssert.ThrowingCallable action = () -> checkstyleWriter.run(); + //then + assertThatThrownBy(action).isInstanceOf(TemplateNotFoundException.class) + .hasMessage("Missing template: garbage"); } // throw RTE if error writing file @@ -185,11 +184,14 @@ public class CheckstyleWriterTest { //given final String imaginary = String.join(FILE_SEPARATOR, "", "..", "imaginary"); outputProperties.setDirectory(Paths.get(imaginary)); - exception.expect(RuntimeException.class); - exception.expectMessage( - "java.nio.file.NoSuchFileException: " + imaginary + FILE_SEPARATOR + "checkstyle-LAYOUT.xml"); //when - checkstyleWriter.run(); + final ThrowableAssert.ThrowingCallable action = () -> checkstyleWriter.run(); + //then + assertThatThrownBy(action).isInstanceOf(CheckstyleWriterException.class) + .hasMessage( + String.format("java.nio.file.NoSuchFileException: %scheckstyle-LAYOUT.xml", + imaginary + FILE_SEPARATOR + )); } private Map.Entry getOutputFile(final RuleLevel level) throws IOException { From 9ac59206a0c0a85de8e224d88a59078c8b4235c6 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Mon, 29 May 2017 11:26:24 +0100 Subject: [PATCH 02/18] KCR28: builder: remove empty test class --- .../CheckstyleWriterExceptionTest.java | 19 ------------------- 1 file changed, 19 deletions(-) delete mode 100644 builder/src/test/java/net/kemitix/checkstyle/ruleset/builder/CheckstyleWriterExceptionTest.java diff --git a/builder/src/test/java/net/kemitix/checkstyle/ruleset/builder/CheckstyleWriterExceptionTest.java b/builder/src/test/java/net/kemitix/checkstyle/ruleset/builder/CheckstyleWriterExceptionTest.java deleted file mode 100644 index ee44130..0000000 --- a/builder/src/test/java/net/kemitix/checkstyle/ruleset/builder/CheckstyleWriterExceptionTest.java +++ /dev/null @@ -1,19 +0,0 @@ -package net.kemitix.checkstyle.ruleset.builder; - -import org.junit.Test; - -/** - * Tests for {@link CheckstyleWriterException}. - * - * @author Paul Campbell (pcampbell@kemitix.net) - */ -public class CheckstyleWriterExceptionTest { - - @Test - public void canCreateException() { - //given - //when - //then - } - -} From f7867283ffa7cb8b3c609213649798de8d279393 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Mon, 29 May 2017 12:24:51 +0100 Subject: [PATCH 03/18] KCr30: CheckstyleWriterTest: checkstyleTemplate: make field local variable --- .../checkstyle/ruleset/builder/CheckstyleWriterTest.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/builder/src/test/java/net/kemitix/checkstyle/ruleset/builder/CheckstyleWriterTest.java b/builder/src/test/java/net/kemitix/checkstyle/ruleset/builder/CheckstyleWriterTest.java index 733908a..f70cbaf 100644 --- a/builder/src/test/java/net/kemitix/checkstyle/ruleset/builder/CheckstyleWriterTest.java +++ b/builder/src/test/java/net/kemitix/checkstyle/ruleset/builder/CheckstyleWriterTest.java @@ -47,8 +47,6 @@ public class CheckstyleWriterTest { private Path outputDirectory; - private Path checkstyleTemplate; - @org.junit.Rule public TemporaryFolder folder = new TemporaryFolder(); @@ -69,8 +67,8 @@ public class CheckstyleWriterTest { .toPath(); outputProperties.setDirectory(outputDirectory); templateProperties = new TemplateProperties(); - checkstyleTemplate = folder.newFile("checkstyle-template.xml") - .toPath(); + val checkstyleTemplate = folder.newFile("checkstyle-template.xml") + .toPath(); Files.write( checkstyleTemplate, TEMPLATE.getBytes(StandardCharsets.UTF_8), StandardOpenOption.TRUNCATE_EXISTING); templateProperties.setCheckstyleXml(checkstyleTemplate); From 27806fb2a2663ca063eab75f94b65b9aa6bd84c4 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Mon, 29 May 2017 12:27:40 +0100 Subject: [PATCH 04/18] KCR31: builder: DefaultRuleReadmeLoaderTest: make field local * fragment (Fixes #31) * templateProperties (Fixes #32) --- .../ruleset/builder/DefaultRuleReadmeLoaderTest.java | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/builder/src/test/java/net/kemitix/checkstyle/ruleset/builder/DefaultRuleReadmeLoaderTest.java b/builder/src/test/java/net/kemitix/checkstyle/ruleset/builder/DefaultRuleReadmeLoaderTest.java index 708d4d2..f7a05f2 100644 --- a/builder/src/test/java/net/kemitix/checkstyle/ruleset/builder/DefaultRuleReadmeLoaderTest.java +++ b/builder/src/test/java/net/kemitix/checkstyle/ruleset/builder/DefaultRuleReadmeLoaderTest.java @@ -23,12 +23,8 @@ public class DefaultRuleReadmeLoaderTest { private RuleReadmeLoader loader; - private TemplateProperties templateProperties; - private Rule rule; - private Path fragment; - private Path fragments; @org.junit.Rule @@ -39,7 +35,7 @@ public class DefaultRuleReadmeLoaderTest { @Before public void setUp() throws Exception { - templateProperties = new TemplateProperties(); + final TemplateProperties templateProperties = new TemplateProperties(); fragments = folder.newFolder("fragments") .toPath(); templateProperties.setReadmeFragments(fragments); @@ -53,8 +49,8 @@ public class DefaultRuleReadmeLoaderTest { public void loadEnabledOkay() throws IOException { //given rule.setEnabled(true); - fragment = fragments.resolve("name.md"); - Files.write(fragment, Arrays.asList("", "body")); + final Path fragment1 = fragments.resolve("name.md"); + Files.write(fragment1, Arrays.asList("", "body")); //when val fragment = loader.load(rule); //then From c4f302d9e513c1ecbdcd45157f7c0fa81b663044 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Mon, 29 May 2017 13:22:25 +0100 Subject: [PATCH 05/18] KCR33: builder: ReadmeWriterTest: outputProperties: make local Fixes #33 --- .../kemitix/checkstyle/ruleset/builder/ReadmeWriterTest.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/builder/src/test/java/net/kemitix/checkstyle/ruleset/builder/ReadmeWriterTest.java b/builder/src/test/java/net/kemitix/checkstyle/ruleset/builder/ReadmeWriterTest.java index bc45598..fa8612f 100644 --- a/builder/src/test/java/net/kemitix/checkstyle/ruleset/builder/ReadmeWriterTest.java +++ b/builder/src/test/java/net/kemitix/checkstyle/ruleset/builder/ReadmeWriterTest.java @@ -27,8 +27,6 @@ public class ReadmeWriterTest { private TemplateProperties templateProperties; - private OutputProperties outputProperties; - private RulesProperties rulesProperties; @Mock @@ -59,7 +57,7 @@ public class ReadmeWriterTest { templateProperties = new TemplateProperties(); templateProperties.setReadmeTemplate(template); templateProperties.setReadmeFragments(fragments); - outputProperties = new OutputProperties(); + final OutputProperties outputProperties = new OutputProperties(); outputProperties.setReadme(readme); rulesProperties = new RulesProperties(); readmeWriter = From d754fdc0a394a7f304dcb40141b7e40631f74d3e Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Mon, 29 May 2017 13:23:37 +0100 Subject: [PATCH 06/18] KCR34: builder: ReadmeWriterTest: template: make local variable --- .../checkstyle/ruleset/builder/ReadmeWriterTest.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/builder/src/test/java/net/kemitix/checkstyle/ruleset/builder/ReadmeWriterTest.java b/builder/src/test/java/net/kemitix/checkstyle/ruleset/builder/ReadmeWriterTest.java index fa8612f..61b584e 100644 --- a/builder/src/test/java/net/kemitix/checkstyle/ruleset/builder/ReadmeWriterTest.java +++ b/builder/src/test/java/net/kemitix/checkstyle/ruleset/builder/ReadmeWriterTest.java @@ -35,8 +35,6 @@ public class ReadmeWriterTest { @Mock private ReadmeIndexBuilder indexBuilder; - private Path template; - private Path fragments; private Path readme; @@ -47,8 +45,8 @@ public class ReadmeWriterTest { @Before public void setUp() throws Exception { MockitoAnnotations.initMocks(this); - template = folder.newFile("README-template.md") - .toPath(); + final Path template = folder.newFile("README-template.md") + .toPath(); Files.write(template, Arrays.asList("i:%s", "ce:%s", "se:%s", "cd:%s", "sd:%s")); fragments = folder.newFolder("fragments") .toPath(); From 74690d8cdfd39356fdb7e8f3516359ea5fd32b74 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Mon, 29 May 2017 13:25:50 +0100 Subject: [PATCH 07/18] KCR35: builder: ReadmeWriterTest: fragments: make local variable --- .../checkstyle/ruleset/builder/ReadmeWriterTest.java | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/builder/src/test/java/net/kemitix/checkstyle/ruleset/builder/ReadmeWriterTest.java b/builder/src/test/java/net/kemitix/checkstyle/ruleset/builder/ReadmeWriterTest.java index 61b584e..df3b34f 100644 --- a/builder/src/test/java/net/kemitix/checkstyle/ruleset/builder/ReadmeWriterTest.java +++ b/builder/src/test/java/net/kemitix/checkstyle/ruleset/builder/ReadmeWriterTest.java @@ -35,8 +35,6 @@ public class ReadmeWriterTest { @Mock private ReadmeIndexBuilder indexBuilder; - private Path fragments; - private Path readme; @org.junit.Rule @@ -48,14 +46,14 @@ public class ReadmeWriterTest { final Path template = folder.newFile("README-template.md") .toPath(); Files.write(template, Arrays.asList("i:%s", "ce:%s", "se:%s", "cd:%s", "sd:%s")); - fragments = folder.newFolder("fragments") - .toPath(); - readme = folder.newFile("README.md") - .toPath(); templateProperties = new TemplateProperties(); templateProperties.setReadmeTemplate(template); + final Path fragments = folder.newFolder("fragments") + .toPath(); templateProperties.setReadmeFragments(fragments); final OutputProperties outputProperties = new OutputProperties(); + readme = folder.newFile("README.md") + .toPath(); outputProperties.setReadme(readme); rulesProperties = new RulesProperties(); readmeWriter = From 701b64e2c6eaebd0132bdf4d68872ebeb25e54aa Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Mon, 29 May 2017 13:27:24 +0100 Subject: [PATCH 08/18] builder: ReadmeWriterTest: templateProperties: make local variable --- .../kemitix/checkstyle/ruleset/builder/ReadmeWriterTest.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/builder/src/test/java/net/kemitix/checkstyle/ruleset/builder/ReadmeWriterTest.java b/builder/src/test/java/net/kemitix/checkstyle/ruleset/builder/ReadmeWriterTest.java index df3b34f..51ad769 100644 --- a/builder/src/test/java/net/kemitix/checkstyle/ruleset/builder/ReadmeWriterTest.java +++ b/builder/src/test/java/net/kemitix/checkstyle/ruleset/builder/ReadmeWriterTest.java @@ -25,8 +25,6 @@ public class ReadmeWriterTest { private ReadmeWriter readmeWriter; - private TemplateProperties templateProperties; - private RulesProperties rulesProperties; @Mock @@ -46,7 +44,7 @@ public class ReadmeWriterTest { final Path template = folder.newFile("README-template.md") .toPath(); Files.write(template, Arrays.asList("i:%s", "ce:%s", "se:%s", "cd:%s", "sd:%s")); - templateProperties = new TemplateProperties(); + final TemplateProperties templateProperties = new TemplateProperties(); templateProperties.setReadmeTemplate(template); final Path fragments = folder.newFolder("fragments") .toPath(); From 4cca4286a15ad566d3a4d7e561fad488893c2609 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Mon, 29 May 2017 13:31:56 +0100 Subject: [PATCH 09/18] KXR36: plugin: DefaultCheckstyleExecutorTest: artifactFile: make local variable --- .../ruleset/plugin/DefaultCheckstyleExecutorTest.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/plugin/src/test/java/net/kemitix/checkstyle/ruleset/plugin/DefaultCheckstyleExecutorTest.java b/plugin/src/test/java/net/kemitix/checkstyle/ruleset/plugin/DefaultCheckstyleExecutorTest.java index b230eeb..8abc7b1 100644 --- a/plugin/src/test/java/net/kemitix/checkstyle/ruleset/plugin/DefaultCheckstyleExecutorTest.java +++ b/plugin/src/test/java/net/kemitix/checkstyle/ruleset/plugin/DefaultCheckstyleExecutorTest.java @@ -72,8 +72,6 @@ public class DefaultCheckstyleExecutorTest { @Mock private Artifact artifact; - private File artifactFile; - @Mock private MavenXpp3Reader mavenXpp3Reader; @@ -122,8 +120,8 @@ public class DefaultCheckstyleExecutorTest { .level(level) .build(); - artifactFile = folder.newFile("pom.xml"); given(artifactRepository.find(any())).willReturn(artifact); + final File artifactFile = folder.newFile("pom.xml"); given(artifact.getFile()).willReturn(artifactFile); given(mavenXpp3Reader.read(any(FileReader.class))).willReturn(pomModel); final Properties properties = new Properties(); From 710cfd151bad6e07bed10c81e9bf373e4214da08 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Mon, 29 May 2017 13:34:52 +0100 Subject: [PATCH 10/18] KCR37: regressions: MoveVariableInsideIf: invalid(): use explicit scope --- .../kemitix/checkstyle/regressions/MoveVariableInsideIf.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/regressions/src/main/java/net/kemitix/checkstyle/regressions/MoveVariableInsideIf.java b/regressions/src/main/java/net/kemitix/checkstyle/regressions/MoveVariableInsideIf.java index bfdb49d..33dc9bd 100644 --- a/regressions/src/main/java/net/kemitix/checkstyle/regressions/MoveVariableInsideIf.java +++ b/regressions/src/main/java/net/kemitix/checkstyle/regressions/MoveVariableInsideIf.java @@ -42,7 +42,7 @@ class MoveVariableInsideIf { * @return value */ @SuppressWarnings("movevariableinsideif") - String invalid() { + private String invalid() { String variable = input.substring(1); if (condition) { return method(variable); From b6521b809c937fa6b68ca9245c1d6276fcb5b709 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Mon, 29 May 2017 13:35:19 +0100 Subject: [PATCH 11/18] KCR38: regressions: MoveVariableInsideIf: valid(): use explicit scope --- .../kemitix/checkstyle/regressions/MoveVariableInsideIf.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/regressions/src/main/java/net/kemitix/checkstyle/regressions/MoveVariableInsideIf.java b/regressions/src/main/java/net/kemitix/checkstyle/regressions/MoveVariableInsideIf.java index 33dc9bd..bea9d91 100644 --- a/regressions/src/main/java/net/kemitix/checkstyle/regressions/MoveVariableInsideIf.java +++ b/regressions/src/main/java/net/kemitix/checkstyle/regressions/MoveVariableInsideIf.java @@ -55,7 +55,7 @@ class MoveVariableInsideIf { * * @return value */ - String valid() { + private String valid() { if (condition) { String variable = input.substring(1); return method(variable); From 55a28392f8b4126a48115b042586c0688eb93d2a Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Mon, 29 May 2017 13:39:04 +0100 Subject: [PATCH 12/18] KCR39: regressions: MoveVariableInsideIf: method(): use parameter --- .../kemitix/checkstyle/regressions/MoveVariableInsideIf.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/regressions/src/main/java/net/kemitix/checkstyle/regressions/MoveVariableInsideIf.java b/regressions/src/main/java/net/kemitix/checkstyle/regressions/MoveVariableInsideIf.java index bfdb49d..dd7dda2 100644 --- a/regressions/src/main/java/net/kemitix/checkstyle/regressions/MoveVariableInsideIf.java +++ b/regressions/src/main/java/net/kemitix/checkstyle/regressions/MoveVariableInsideIf.java @@ -33,7 +33,7 @@ class MoveVariableInsideIf { private boolean condition; private String method(final String variable) { - return "value"; + return "value: " + variable; } /** From 1a5ca4ceef1df94a255e8ef7751e23e619fe0010 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Mon, 29 May 2017 14:10:04 +0100 Subject: [PATCH 13/18] KCR37+38: MoveVariableInsideIf: avoid unused private methods --- .../kemitix/checkstyle/regressions/MoveVariableInsideIf.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/regressions/src/main/java/net/kemitix/checkstyle/regressions/MoveVariableInsideIf.java b/regressions/src/main/java/net/kemitix/checkstyle/regressions/MoveVariableInsideIf.java index bea9d91..a13ccb3 100644 --- a/regressions/src/main/java/net/kemitix/checkstyle/regressions/MoveVariableInsideIf.java +++ b/regressions/src/main/java/net/kemitix/checkstyle/regressions/MoveVariableInsideIf.java @@ -42,7 +42,7 @@ class MoveVariableInsideIf { * @return value */ @SuppressWarnings("movevariableinsideif") - private String invalid() { + protected String invalid() { String variable = input.substring(1); if (condition) { return method(variable); @@ -55,7 +55,7 @@ class MoveVariableInsideIf { * * @return value */ - private String valid() { + protected String valid() { if (condition) { String variable = input.substring(1); return method(variable); From 9b571a5a582a001bf33a34e15cf3a2044614c213 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Mon, 29 May 2017 14:20:16 +0100 Subject: [PATCH 14/18] travis-ci: only deploy from Travis-CI --- travis-ci/travis-deploy.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/travis-ci/travis-deploy.sh b/travis-ci/travis-deploy.sh index 240dd26..cdc921b 100755 --- a/travis-ci/travis-deploy.sh +++ b/travis-ci/travis-deploy.sh @@ -1,6 +1,8 @@ #!/usr/bin/env bash -if [ "$TRAVIS_BRANCH" = 'master' ] && [ "$TRAVIS_PULL_REQUEST" == 'false' ]; then +## Only deploy from Travis-CI. Some CIs, like Shippable, lie by setting TRAVIS=true. +## Currently, Shippable, does not set TRAVIS_LANGUAGE, but Travis-CI does. +if [ "$TRAVIS_LANGUAGE" = "java" ] && [ "$TRAVIS_BRANCH" = 'master' ] && [ "$TRAVIS_PULL_REQUEST" == 'false' ]; then openssl aes-256-cbc -K $encrypted_efec3258f55d_key -iv $encrypted_efec3258f55d_iv \ -in travis-ci/codesigning.asc.enc -out travis-ci/codesigning.asc -d gpg --batch --fast-import travis-ci/codesigning.asc From 02087630c93f1a90346340e58b0a1c725752e1c4 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Mon, 29 May 2017 14:40:21 +0100 Subject: [PATCH 15/18] shippable.yml: added --- shippable.yml | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 shippable.yml diff --git a/shippable.yml b/shippable.yml new file mode 100644 index 0000000..3d074c8 --- /dev/null +++ b/shippable.yml @@ -0,0 +1,8 @@ +language: java +jdk: +- oraclejdk8 +cache: + directories: + - "$HOME/.m2" +install: true +script: "./mvnw clean install" From 8c5a6e06fddbbb707730e1efe2563b82f3d8c834 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Mon, 29 May 2017 14:46:59 +0100 Subject: [PATCH 16/18] travis-ci: remove defensive checks --- travis-ci/travis-coveralls-report.sh | 6 +----- travis-ci/travis-deploy.sh | 4 +--- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/travis-ci/travis-coveralls-report.sh b/travis-ci/travis-coveralls-report.sh index 5ef727d..aab1704 100755 --- a/travis-ci/travis-coveralls-report.sh +++ b/travis-ci/travis-coveralls-report.sh @@ -1,7 +1,3 @@ #!/usr/bin/env bash -## Only send coveralls reports from Travis-CI. Some CIs, like Shippable, lie by setting TRAVIS=true. -## Currently, Shippable, does not set TRAVIS_LANGUAGE, but Travis-CI does. -if [ "$TRAVIS_LANGUAGE" = "java" ];then - ./mvnw --projects builder,plugin test jacoco:report coveralls:report -fi +./mvnw --projects builder,plugin test jacoco:report coveralls:report diff --git a/travis-ci/travis-deploy.sh b/travis-ci/travis-deploy.sh index cdc921b..240dd26 100755 --- a/travis-ci/travis-deploy.sh +++ b/travis-ci/travis-deploy.sh @@ -1,8 +1,6 @@ #!/usr/bin/env bash -## Only deploy from Travis-CI. Some CIs, like Shippable, lie by setting TRAVIS=true. -## Currently, Shippable, does not set TRAVIS_LANGUAGE, but Travis-CI does. -if [ "$TRAVIS_LANGUAGE" = "java" ] && [ "$TRAVIS_BRANCH" = 'master' ] && [ "$TRAVIS_PULL_REQUEST" == 'false' ]; then +if [ "$TRAVIS_BRANCH" = 'master' ] && [ "$TRAVIS_PULL_REQUEST" == 'false' ]; then openssl aes-256-cbc -K $encrypted_efec3258f55d_key -iv $encrypted_efec3258f55d_iv \ -in travis-ci/codesigning.asc.enc -out travis-ci/codesigning.asc -d gpg --batch --fast-import travis-ci/codesigning.asc From da5a14c1cea2e1a38cee58d42800cf05765e8ffe Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Mon, 29 May 2017 14:52:04 +0100 Subject: [PATCH 17/18] wercker.yml: added --- wercker.yml | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 wercker.yml diff --git a/wercker.yml b/wercker.yml new file mode 100644 index 0000000..4c50a59 --- /dev/null +++ b/wercker.yml @@ -0,0 +1,7 @@ +box: maven:3.5.0-jdk-8 + +build: + steps: + - script: + name: maven clean install + code: ./mvnw clean install From 5b9e32d2eb469c5e85482a617dd4d70d4d3d72ca Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Mon, 29 May 2017 14:56:51 +0100 Subject: [PATCH 18/18] wercker.yml: rewritten --- wercker.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/wercker.yml b/wercker.yml index 4c50a59..b152705 100644 --- a/wercker.yml +++ b/wercker.yml @@ -2,6 +2,5 @@ box: maven:3.5.0-jdk-8 build: steps: - - script: - name: maven clean install - code: ./mvnw clean install + - xenoterracide/maven: + goals: clean install