From af89497f4d4aad45333b432a2c59b184a9bf153c Mon Sep 17 00:00:00 2001 From: Yegor Bugayenko Date: Thu, 7 Mar 2024 10:54:35 +0300 Subject: [PATCH] #1198 filter out non-java files --- .../checkstyle/CheckstyleValidator.java | 8 ++- .../src/it/checkstyle-locale/LICENSE.txt | 28 -------- .../it/checkstyle-locale/invoker.properties | 3 - .../src/it/checkstyle-locale/pom.xml | 66 ------------------- .../src/main/resources/tabs.txt | 1 - .../src/it/checkstyle-locale/verify.groovy | 38 ----------- .../it/checkstyle-violations/verify.groovy | 2 - .../java/com/qulice/pmd/PmdValidator.java | 8 ++- 8 files changed, 12 insertions(+), 142 deletions(-) delete mode 100644 qulice-maven-plugin/src/it/checkstyle-locale/LICENSE.txt delete mode 100644 qulice-maven-plugin/src/it/checkstyle-locale/invoker.properties delete mode 100644 qulice-maven-plugin/src/it/checkstyle-locale/pom.xml delete mode 100644 qulice-maven-plugin/src/it/checkstyle-locale/src/main/resources/tabs.txt delete mode 100644 qulice-maven-plugin/src/it/checkstyle-locale/verify.groovy 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 67f4a802e..e2d6487c1 100644 --- a/qulice-checkstyle/src/main/java/com/qulice/checkstyle/CheckstyleValidator.java +++ b/qulice-checkstyle/src/main/java/com/qulice/checkstyle/CheckstyleValidator.java @@ -144,9 +144,13 @@ public List getNonExcludedFiles(final Collection files) { final String name = file.getPath().substring( this.env.basedir().toString().length() ); - if (!this.env.exclude("checkstyle", name)) { - relevant.add(file); + if (this.env.exclude("checkstyle", name)) { + continue; } + if (!name.matches("^.*\\.java$")) { + continue; + } + relevant.add(file); } return relevant; } diff --git a/qulice-maven-plugin/src/it/checkstyle-locale/LICENSE.txt b/qulice-maven-plugin/src/it/checkstyle-locale/LICENSE.txt deleted file mode 100644 index 7513aa031..000000000 --- a/qulice-maven-plugin/src/it/checkstyle-locale/LICENSE.txt +++ /dev/null @@ -1,28 +0,0 @@ -Copyright (c) 2011-2024 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-maven-plugin/src/it/checkstyle-locale/invoker.properties b/qulice-maven-plugin/src/it/checkstyle-locale/invoker.properties deleted file mode 100644 index 848e66650..000000000 --- a/qulice-maven-plugin/src/it/checkstyle-locale/invoker.properties +++ /dev/null @@ -1,3 +0,0 @@ -invoker.goals = clean verify -invoker.buildResult = failure -invoker.mavenOpts=-Duser.language=fr -Duser.country=FR \ No newline at end of file diff --git a/qulice-maven-plugin/src/it/checkstyle-locale/pom.xml b/qulice-maven-plugin/src/it/checkstyle-locale/pom.xml deleted file mode 100644 index e9835bad4..000000000 --- a/qulice-maven-plugin/src/it/checkstyle-locale/pom.xml +++ /dev/null @@ -1,66 +0,0 @@ - - - - 4.0.0 - - com.jcabi - parent - 0.54.1 - - com.qulice.plugin - checkstyle-locale - 1.0-SNAPSHOT - jar - checkstyle-locale - - 3.0 - - - - - com.qulice - qulice-maven-plugin - @project.version@ - - file:${basedir}/LICENSE.txt - - - - - check - - - - - - - diff --git a/qulice-maven-plugin/src/it/checkstyle-locale/src/main/resources/tabs.txt b/qulice-maven-plugin/src/it/checkstyle-locale/src/main/resources/tabs.txt deleted file mode 100644 index 90224546f..000000000 --- a/qulice-maven-plugin/src/it/checkstyle-locale/src/main/resources/tabs.txt +++ /dev/null @@ -1 +0,0 @@ -This file contains a tab. \ No newline at end of file diff --git a/qulice-maven-plugin/src/it/checkstyle-locale/verify.groovy b/qulice-maven-plugin/src/it/checkstyle-locale/verify.groovy deleted file mode 100644 index cb9d454f7..000000000 --- a/qulice-maven-plugin/src/it/checkstyle-locale/verify.groovy +++ /dev/null @@ -1,38 +0,0 @@ -/** - * - * Copyright (c) 2011-2024, 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. - * - * - * Validate that the build really failed and violations were reported in - * English language. - */ - -def log = new File(basedir, 'build.log') -assert log.text.contains('Line contains a tab character') diff --git a/qulice-maven-plugin/src/it/checkstyle-violations/verify.groovy b/qulice-maven-plugin/src/it/checkstyle-violations/verify.groovy index 52b8af033..477e56a43 100644 --- a/qulice-maven-plugin/src/it/checkstyle-violations/verify.groovy +++ b/qulice-maven-plugin/src/it/checkstyle-violations/verify.groovy @@ -36,14 +36,12 @@ def log = new File(basedir, 'build.log') assert log.text.findAll('.*Brackets.java.*BracketsStructureCheck').size() == 4 assert log.text.contains('Tabs.java[4]: Line contains a tab character. (FileTabCharacterCheck)') -assert log.text.contains('tabs.txt[1]: Line contains a tab character. (FileTabCharacterCheck)') assert log.text.findAll('Brackets.java.*(HeaderCheck)').empty //assert log.text.contains('Violations.java[6]: This method must be static, because it does not refer to "this"') assert log.text.contains('Brackets.java[54]: Closing bracket should be on a new line (BracketsStructureCheck)') assert log.text.contains('Violations.java[14]: Parameter txt should be final. (FinalParametersCheck)') assert log.text.contains('Violations.java[25]: Parameter ex should be final. (FinalParametersCheck)') assert log.text.contains('NewLines.java[4]: Lines in file should end with Unix-like end of line') -assert log.text.contains('newlines.txt[3]: Lines in file should end with Unix-like end of line') assert log.text.contains('Violations.java[33]: ArrayList should be initialized with a size parameter') assert log.text.contains('Violations.java[34]: ArrayList should be initialized with a size parameter') assert !log.text.contains('Got an exception - java.lang.NullPointerException') diff --git a/qulice-pmd/src/main/java/com/qulice/pmd/PmdValidator.java b/qulice-pmd/src/main/java/com/qulice/pmd/PmdValidator.java index a9536b6bd..229873c74 100644 --- a/qulice-pmd/src/main/java/com/qulice/pmd/PmdValidator.java +++ b/qulice-pmd/src/main/java/com/qulice/pmd/PmdValidator.java @@ -98,9 +98,13 @@ public Collection getNonExcludedFiles(final Collection files) final String name = file.getPath().substring( this.env.basedir().toString().length() ); - if (!this.env.exclude("pmd", name)) { - sources.add(new FileDataSource(file)); + if (this.env.exclude("pmd", name)) { + continue; } + if (!name.matches("^.*\\.java$")) { + continue; + } + sources.add(new FileDataSource(file)); } return sources; }