From 277d04dafb35aeb36accb4e620d19a744ad173d0 Mon Sep 17 00:00:00 2001 From: Yegor Bugayenko Date: Wed, 13 Jul 2022 17:09:55 +0300 Subject: [PATCH] #1092 parent up --- pom.xml | 16 ++++++----- .../checkstyle/CheckstyleValidator.java | 20 ++++++++------ .../checkstyle/CheckstyleValidatorTest.java | 9 ++++--- .../java/com/qulice/checkstyle/License.java | 3 ++- .../src/test/resources/LICENSE.txt | 27 +++++++++++++++++++ .../qulice/pmd/UseStringIsEmptyRuleTest.java | 2 +- 6 files changed, 57 insertions(+), 20 deletions(-) create mode 100644 qulice-maven-plugin/src/test/resources/LICENSE.txt diff --git a/pom.xml b/pom.xml index 6b3b4f371..e523cc439 100644 --- a/pom.xml +++ b/pom.xml @@ -104,7 +104,7 @@ OF THE POSSIBILITY OF SUCH DAMAGE. org.projectlombok lombok - 1.18.20 + 1.18.24 provided @@ -115,17 +115,17 @@ OF THE POSSIBILITY OF SUCH DAMAGE. com.jcabi jcabi-xml - 0.23.1 + 0.23.2 com.jcabi jcabi-log - 0.20.0 + 0.20.1 com.jcabi jcabi-aspects - 0.23.2 + 0.24.1 provided @@ -147,7 +147,7 @@ OF THE POSSIBILITY OF SUCH DAMAGE. org.cactoos cactoos - 0.41 + 0.51.0 org.junit.jupiter @@ -170,12 +170,14 @@ OF THE POSSIBILITY OF SUCH DAMAGE. org.hamcrest hamcrest-core - 1.3 + 2.2 + test org.hamcrest hamcrest-library - 1.3 + 2.2 + test org.slf4j diff --git a/qulice-checkstyle/src/main/java/com/qulice/checkstyle/CheckstyleValidator.java b/qulice-checkstyle/src/main/java/com/qulice/checkstyle/CheckstyleValidator.java index 91104bb20..088183327 100644 --- a/qulice-checkstyle/src/main/java/com/qulice/checkstyle/CheckstyleValidator.java +++ b/qulice-checkstyle/src/main/java/com/qulice/checkstyle/CheckstyleValidator.java @@ -49,9 +49,11 @@ import java.util.List; import java.util.Properties; import org.apache.commons.lang3.StringUtils; +import org.cactoos.text.IoCheckedText; import org.cactoos.text.Replaced; import org.cactoos.text.TextOf; import org.cactoos.text.Trimmed; +import org.cactoos.text.UncheckedText; import org.xml.sax.InputSource; /** @@ -192,14 +194,16 @@ private String header() { final URL url = this.toUrl(name); final String content; try { - content = new Replaced( - new Trimmed( - new TextOf( - url.openStream() - ) - ), - "[\\r\\n]+$", - "" + content = new IoCheckedText( + new Replaced( + new Trimmed( + new TextOf( + url.openStream() + ) + ), + "[\\r\\n]+$", + "" + ) ).asString(); } catch (final IOException ex) { throw new IllegalStateException("Failed to read license", ex); diff --git a/qulice-checkstyle/src/test/java/com/qulice/checkstyle/CheckstyleValidatorTest.java b/qulice-checkstyle/src/test/java/com/qulice/checkstyle/CheckstyleValidatorTest.java index f72e9650a..ee82fb1e5 100644 --- a/qulice-checkstyle/src/test/java/com/qulice/checkstyle/CheckstyleValidatorTest.java +++ b/qulice-checkstyle/src/test/java/com/qulice/checkstyle/CheckstyleValidatorTest.java @@ -39,6 +39,7 @@ import org.cactoos.io.ResourceOf; import org.cactoos.list.ListOf; import org.cactoos.text.FormattedText; +import org.cactoos.text.IoCheckedText; import org.cactoos.text.Joined; import org.cactoos.text.TextOf; import org.hamcrest.Description; @@ -792,9 +793,11 @@ private Collection runValidation(final String file, ) .withFile( String.format("src/main/java/foo/%s", file), - new TextOf( - new ResourceOf( - new FormattedText("com/qulice/checkstyle/%s", file) + new IoCheckedText( + new TextOf( + new ResourceOf( + new FormattedText("com/qulice/checkstyle/%s", file) + ) ) ).asString() ); diff --git a/qulice-checkstyle/src/test/java/com/qulice/checkstyle/License.java b/qulice-checkstyle/src/test/java/com/qulice/checkstyle/License.java index 0eb82fc07..2b58c874d 100644 --- a/qulice-checkstyle/src/test/java/com/qulice/checkstyle/License.java +++ b/qulice-checkstyle/src/test/java/com/qulice/checkstyle/License.java @@ -34,6 +34,7 @@ import java.io.IOException; import java.nio.charset.StandardCharsets; import org.apache.commons.io.FileUtils; +import org.cactoos.text.IoCheckedText; import org.cactoos.text.Joined; /** @@ -113,7 +114,7 @@ public File file() throws IOException { FileUtils.forceDeleteOnExit(license); FileUtils.writeStringToFile( license, - new Joined(this.eol, this.lines).asString(), + new IoCheckedText(new Joined(this.eol, this.lines)).asString(), StandardCharsets.UTF_8 ); if (this.directory != null) { diff --git a/qulice-maven-plugin/src/test/resources/LICENSE.txt b/qulice-maven-plugin/src/test/resources/LICENSE.txt new file mode 100644 index 000000000..931cee9e6 --- /dev/null +++ b/qulice-maven-plugin/src/test/resources/LICENSE.txt @@ -0,0 +1,27 @@ +Copyright (c) 2011-2022 Qulice.com +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: 1) Redistributions of source code must retain the above +copyright notice, this list of conditions and the following +disclaimer. 2) Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the following +disclaimer in the documentation and/or other materials provided +with the distribution. 3) Neither the name of the Qulice.com nor +the names of its contributors may be used to endorse or promote +products derived from this software without specific prior written +permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT +NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL +THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, +INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, +STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED +OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/qulice-pmd/src/test/java/com/qulice/pmd/UseStringIsEmptyRuleTest.java b/qulice-pmd/src/test/java/com/qulice/pmd/UseStringIsEmptyRuleTest.java index f343023a0..0601c30d5 100644 --- a/qulice-pmd/src/test/java/com/qulice/pmd/UseStringIsEmptyRuleTest.java +++ b/qulice-pmd/src/test/java/com/qulice/pmd/UseStringIsEmptyRuleTest.java @@ -84,7 +84,7 @@ public void notDetectOnArrayOfStrings() throws Exception { new PmdAssert( "ArrayOfStringsLengthGreaterThanZero.java", new IsEqual<>(true), - new IsEmptyString() + IsEmptyString.emptyString() ).validate(); }