From 22b661db4913788fddfc618326368a935158ac84 Mon Sep 17 00:00:00 2001 From: Yegor Bugayenko Date: Thu, 7 Mar 2024 17:25:51 +0300 Subject: [PATCH] #1198: checkstyle up --- pom.xml | 6 - qulice-ant/LICENSE.txt | 28 --- qulice-ant/pom.xml | 182 ---------------- qulice-ant/src/it/settings.xml | 65 ------ qulice-ant/src/it/violations/LICENSE.txt | 28 --- qulice-ant/src/it/violations/build.xml | 38 ---- .../src/it/violations/invoker.properties | 2 - qulice-ant/src/it/violations/pom.xml | 79 ------- .../src/main/java/com/qulice/foo/Main.java | 64 ------ .../java/com/qulice/foo/package-info.java | 31 --- qulice-ant/src/it/violations/verify.groovy | 37 ---- .../java/com/qulice/ant/AntEnvironment.java | 206 ------------------ .../src/main/java/com/qulice/ant/AntPath.java | 95 -------- .../main/java/com/qulice/ant/AntProject.java | 130 ----------- .../main/java/com/qulice/ant/QuliceTask.java | 197 ----------------- .../java/com/qulice/ant/package-info.java | 37 ---- qulice-ant/src/site/apt/index.apt.vm | 66 ------ qulice-ant/src/site/site.xml | 40 ---- .../com/qulice/ant/AntEnvironmentTest.java | 91 -------- .../java/com/qulice/ant/package-info.java | 37 ---- qulice-checkstyle/pom.xml | 18 +- .../checkstyle/JavadocLocationCheck.java | 99 ++------- .../JavadocParameterOrderCheck.java | 1 + .../NoJavadocForOverriddenMethodsCheck.java | 1 + .../checkstyle/NonStaticMethodCheck.java | 2 + .../com/qulice/checkstyle/checks.xml | 67 +++--- .../com/qulice/checkstyle/ChecksTest.java | 5 +- .../ChecksTest/EmptyLinesCheck/Valid.java | 2 +- .../JavadocLocationCheck/Valid.java | 6 + .../qulice/checkstyle/ValidIndentation.java | 2 +- 30 files changed, 75 insertions(+), 1587 deletions(-) delete mode 100644 qulice-ant/LICENSE.txt delete mode 100644 qulice-ant/pom.xml delete mode 100644 qulice-ant/src/it/settings.xml delete mode 100644 qulice-ant/src/it/violations/LICENSE.txt delete mode 100644 qulice-ant/src/it/violations/build.xml delete mode 100644 qulice-ant/src/it/violations/invoker.properties delete mode 100644 qulice-ant/src/it/violations/pom.xml delete mode 100644 qulice-ant/src/it/violations/src/main/java/com/qulice/foo/Main.java delete mode 100644 qulice-ant/src/it/violations/src/main/java/com/qulice/foo/package-info.java delete mode 100644 qulice-ant/src/it/violations/verify.groovy delete mode 100644 qulice-ant/src/main/java/com/qulice/ant/AntEnvironment.java delete mode 100644 qulice-ant/src/main/java/com/qulice/ant/AntPath.java delete mode 100644 qulice-ant/src/main/java/com/qulice/ant/AntProject.java delete mode 100644 qulice-ant/src/main/java/com/qulice/ant/QuliceTask.java delete mode 100644 qulice-ant/src/main/java/com/qulice/ant/package-info.java delete mode 100644 qulice-ant/src/site/apt/index.apt.vm delete mode 100644 qulice-ant/src/site/site.xml delete mode 100644 qulice-ant/src/test/java/com/qulice/ant/AntEnvironmentTest.java delete mode 100644 qulice-ant/src/test/java/com/qulice/ant/package-info.java diff --git a/pom.xml b/pom.xml index 38de49356..49c102da6 100644 --- a/pom.xml +++ b/pom.xml @@ -42,7 +42,6 @@ OF THE POSSIBILITY OF SUCH DAMAGE. pom qulice - qulice-ant qulice-checkstyle qulice-maven-plugin qulice-pmd @@ -97,11 +96,6 @@ OF THE POSSIBILITY OF SUCH DAMAGE. - - org.antlr - antlr4-runtime - 4.13.1 - org.projectlombok lombok diff --git a/qulice-ant/LICENSE.txt b/qulice-ant/LICENSE.txt deleted file mode 100644 index 7513aa031..000000000 --- a/qulice-ant/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-ant/pom.xml b/qulice-ant/pom.xml deleted file mode 100644 index 21222128b..000000000 --- a/qulice-ant/pom.xml +++ /dev/null @@ -1,182 +0,0 @@ - - - - 4.0.0 - - com.qulice - qulice - 1.0-SNAPSHOT - - qulice-ant - jar - qulice-ant - - - com.qulice - qulice-checkstyle - ${project.version} - - - com.qulice - qulice-pmd - ${project.version} - - - ant - ant - - - - com.ibm.icu - icu4j - - - xerces - xmlParserAPIs - - - net.java.dev.javacc - javacc - - - - - com.qulice - qulice-spi - ${project.version} - - - com.jcabi - jcabi-log - - - - com.jcabi - jcabi-aspects - - provided - - - org.apache.ant - ant - 1.10.13 - - - commons-io - commons-io - - - - org.junit.jupiter - junit-jupiter-api - - - - org.junit.jupiter - junit-jupiter-engine - - - - org.slf4j - slf4j-log4j12 - - - - log4j - log4j - - - - - - - maven-invoker-plugin - - false - - violations/pom.xml - - - ${project.groupId}:qulice-checkstyle:${project.version}:jar - ${project.groupId}:qulice-pmd:${project.version}:jar - ${project.groupId}:qulice-spi:${project.version}:jar - - - - - ${project.groupId} - qulice-checkstyle - ${project.version} - - - ${project.groupId} - qulice-pmd - ${project.version} - - - ${project.groupId} - qulice-spi - ${project.version} - - - - - com.github.github - site-maven-plugin - - ${project.artifactId} - - - - - - - qulice - - - - com.qulice - qulice-maven-plugin - - - checkstyle:/src/it/.* - pmd:.*/src/it/.* - xml:/src/it/.* - duplicatefinder:.* - - - - - - - - diff --git a/qulice-ant/src/it/settings.xml b/qulice-ant/src/it/settings.xml deleted file mode 100644 index b286f35f2..000000000 --- a/qulice-ant/src/it/settings.xml +++ /dev/null @@ -1,65 +0,0 @@ - - - - - - it-repo - - true - - - - local.central - @localRepositoryUrl@ - - true - - - true - - - - - - local.central - @localRepositoryUrl@ - - true - - - true - - - - - - diff --git a/qulice-ant/src/it/violations/LICENSE.txt b/qulice-ant/src/it/violations/LICENSE.txt deleted file mode 100644 index 7513aa031..000000000 --- a/qulice-ant/src/it/violations/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-ant/src/it/violations/build.xml b/qulice-ant/src/it/violations/build.xml deleted file mode 100644 index 0b2ce8fe8..000000000 --- a/qulice-ant/src/it/violations/build.xml +++ /dev/null @@ -1,38 +0,0 @@ - - - - - - - - - diff --git a/qulice-ant/src/it/violations/invoker.properties b/qulice-ant/src/it/violations/invoker.properties deleted file mode 100644 index 2f860cb08..000000000 --- a/qulice-ant/src/it/violations/invoker.properties +++ /dev/null @@ -1,2 +0,0 @@ -invoker.goals = clean verify -invoker.buildResult = failure diff --git a/qulice-ant/src/it/violations/pom.xml b/qulice-ant/src/it/violations/pom.xml deleted file mode 100644 index cb5f58259..000000000 --- a/qulice-ant/src/it/violations/pom.xml +++ /dev/null @@ -1,79 +0,0 @@ - - - - 4.0.0 - - com.jcabi - parent - 0.54.1 - - com.qulice.plugin - violations - 1.0-SNAPSHOT - jar - violations - - - - org.apache.maven.plugins - maven-antrun-plugin - 1.7 - - - com.qulice - qulice-ant - @project.version@ - - - - - antrun - integration-test - - - - - - - - - - - - run - - - - - - - diff --git a/qulice-ant/src/it/violations/src/main/java/com/qulice/foo/Main.java b/qulice-ant/src/it/violations/src/main/java/com/qulice/foo/Main.java deleted file mode 100644 index ba32bb03b..000000000 --- a/qulice-ant/src/it/violations/src/main/java/com/qulice/foo/Main.java +++ /dev/null @@ -1,64 +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. - */ -package com.qulice.foo; - -import java.net.URL; -import java.util.HashSet; -import java.util.Set; - -/** - * This is just a test class. - * @since 1.0 - */ -public final class Main { - - /** - * List of some URLs. - */ - private final transient Set list; - - /** - * Test something. - */ - public Main() { - this.list = new HashSet(500); - System.out.println("Hello, world!"); - } - - /** - * Get size of list. - * @return The size - */ - public int size() { - return this.list.size(); - } - -} diff --git a/qulice-ant/src/it/violations/src/main/java/com/qulice/foo/package-info.java b/qulice-ant/src/it/violations/src/main/java/com/qulice/foo/package-info.java deleted file mode 100644 index a83c5cc28..000000000 --- a/qulice-ant/src/it/violations/src/main/java/com/qulice/foo/package-info.java +++ /dev/null @@ -1,31 +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. - */ -package com.qulice.foo; diff --git a/qulice-ant/src/it/violations/verify.groovy b/qulice-ant/src/it/violations/verify.groovy deleted file mode 100644 index 106cb379b..000000000 --- a/qulice-ant/src/it/violations/verify.groovy +++ /dev/null @@ -1,37 +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. - */ - -def log = new File(basedir, 'build.log') -assert log.text.contains('ConstructorOnlyInitializesOrCallOtherConstructors') diff --git a/qulice-ant/src/main/java/com/qulice/ant/AntEnvironment.java b/qulice-ant/src/main/java/com/qulice/ant/AntEnvironment.java deleted file mode 100644 index 4b1e7fcbd..000000000 --- a/qulice-ant/src/main/java/com/qulice/ant/AntEnvironment.java +++ /dev/null @@ -1,206 +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. - */ -package com.qulice.ant; - -import com.jcabi.log.Logger; -import com.qulice.spi.Environment; -import java.io.File; -import java.net.MalformedURLException; -import java.net.URL; -import java.net.URLClassLoader; -import java.security.PrivilegedAction; -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import java.util.LinkedList; -import java.util.List; -import org.apache.commons.io.FileUtils; -import org.apache.commons.io.filefilter.DirectoryFileFilter; -import org.apache.commons.io.filefilter.IOFileFilter; -import org.apache.commons.io.filefilter.WildcardFileFilter; - -/** - * Environment, passed from ant task to validators. - * @since 0.13 - */ -public final class AntEnvironment implements Environment { - - /** - * Ant project. - */ - private final AntProject project; - - /** - * Sources dirs. - */ - private final AntPath sources; - - /** - * Classes dir (only one dir is supported). - */ - private final File classes; - - /** - * Classpath dirs and files. - */ - @SuppressWarnings("PMD.AvoidFieldNameMatchingMethodName") - private final AntPath classpath; - - /** - * Public ctor. - * @param prjct Ant project - * @param srcs Sources dirs - * @param clss Classes dir - * @param clsspth Classpath - * @checkstyle ParameterNumber (5 lines) - */ - public AntEnvironment( - final AntProject prjct, - final AntPath srcs, - final File clss, - final AntPath clsspth) { - this.project = prjct; - this.sources = srcs; - this.classes = clss; - this.classpath = clsspth; - } - - @Override - public File basedir() { - return this.project.getBaseDir(); - } - - @Override - public File tempdir() { - return new File(this.basedir(), "temp"); - } - - @Override - public File outdir() { - return this.classes; - } - - @Override - public String param(final String name, final String value) { - String property = this.project.getProperty(name); - if (property == null) { - property = value; - } - return property; - } - - @Override - @SuppressWarnings("PMD.AvoidInstantiatingObjectsInLoops") - public ClassLoader classloader() { - final List urls = new LinkedList<>(); - try { - for (final String path : this.classpath()) { - urls.add( - new File(path).toURI().toURL() - ); - } - urls.add(this.classes.toURI().toURL()); - } catch (final MalformedURLException ex) { - throw new IllegalStateException("Failed to build URL", ex); - } - final URLClassLoader loader = - new AntEnvironment.PrivilegedClassLoader(urls).run(); - for (final URL url : loader.getURLs()) { - Logger.debug(this, "Classpath: %s", url); - } - return loader; - } - - @Override - public Collection classpath() { - return Arrays.asList(this.classpath.list()); - } - - @Override - @SuppressWarnings("PMD.AvoidInstantiatingObjectsInLoops") - public Collection files(final String pattern) { - final Collection files = new LinkedList<>(); - final IOFileFilter filter = new WildcardFileFilter(pattern); - for (final String dir : this.sources.list()) { - final File source = new File(dir); - if (source.exists() && source.isDirectory()) { - files.addAll( - FileUtils.listFiles( - source, - filter, - DirectoryFileFilter.INSTANCE - ) - ); - } - } - return files; - } - - @Override - // @todo #337 Implement exclude and excludes for ant QuliceTask - public boolean exclude(final String check, final String name) { - return false; - } - - @Override - public Collection excludes(final String checker) { - return Collections.emptyList(); - } - - /** - * Creates URL ClassLoader in privileged block. - * - * @since 0.1 - */ - private static final class PrivilegedClassLoader implements - PrivilegedAction { - /** - * URLs for class loading. - */ - private final List urls; - - /** - * Constructor. - * @param urls URLs for class loading. - */ - private PrivilegedClassLoader(final List urls) { - this.urls = urls; - } - - @Override - public URLClassLoader run() { - return new URLClassLoader( - this.urls.toArray(new URL[this.urls.size()]), - Thread.currentThread().getContextClassLoader() - ); - } - } -} diff --git a/qulice-ant/src/main/java/com/qulice/ant/AntPath.java b/qulice-ant/src/main/java/com/qulice/ant/AntPath.java deleted file mode 100644 index a7691d080..000000000 --- a/qulice-ant/src/main/java/com/qulice/ant/AntPath.java +++ /dev/null @@ -1,95 +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. - */ -package com.qulice.ant; - -import org.apache.tools.ant.types.Path; - -/** - * Represents subset of org.apache.tools.ant.types.Path API which is relevant to Qulice. - * - * @since 1.0 - */ -public interface AntPath { - /** - * Returns all indivudual pathes of this path. - * @return List of elements. - */ - String[] list(); - - /** - * Default implementation which wraps Ant path. - * @since 1.0 - */ - class Default implements AntPath { - /** - * Wrapped path. - */ - private final Path path; - - /** - * Returns AntPath equivalent to the given path. - * @param path A path to wrap. - */ - Default(final Path path) { - this.path = path; - } - - @Override - public String[] list() { - return this.path.list(); - } - } - - /** - * Simple implementation for tests. - * @since 1.0 - */ - class Fake implements AntPath { - /** - * Result for the list() method. - */ - private final String[] listres; - - /** - * Creates fake AntPath. - * @param listres Array to return from the list(), assumed to be immutable. - * @since 1.0 - */ - Fake(final String... listres) { - this.listres = listres; - } - - @Override - public String[] list() { - return this.listres; - } - } -} diff --git a/qulice-ant/src/main/java/com/qulice/ant/AntProject.java b/qulice-ant/src/main/java/com/qulice/ant/AntProject.java deleted file mode 100644 index 09b0e0b58..000000000 --- a/qulice-ant/src/main/java/com/qulice/ant/AntProject.java +++ /dev/null @@ -1,130 +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. - */ -package com.qulice.ant; - -import java.io.File; -import java.util.function.Function; -import java.util.function.Supplier; -import org.apache.tools.ant.Project; - -/** - * Represents subset of org.apache.tools.ant.Project API which is relevant to Qulice. - * - * @since 1.0 - */ -interface AntProject { - /** - * Returns Ant project property. - * - * @param property Name of the property to get. - * @return Property value or null. - */ - String getProperty(String property); - - /** - * Returns Ant project base directory. - * - * @return Base directory. - */ - File getBaseDir(); - - /** - * Default implementation which wraps Ant Project. - * @since 1.0 - */ - class Default implements AntProject { - /** - * Wrapped project. - */ - private final Project project; - - /** - * Creates a new AntProject equivalent to the given Project. - * @param project Project to wrap. - */ - Default(final Project project) { - this.project = project; - } - - @Override - public String getProperty(final String property) { - return this.project.getProperty(property); - } - - @Override - public File getBaseDir() { - return this.project.getBaseDir(); - } - } - - /** - * Fake implementation of AntProject which allows caller to - * customize both methods with lambdas. - * - * @since 1.0 - */ - class Fake implements AntProject { - /** - * Implementation of the getProperty() method. - */ - private final Function prop; - - /** - * Implementation of the getBaseDir() method. - */ - private final Supplier basedir; - - /** - * Creates a new FakeAntProject which will use provided - * functions. - * - * @param prop Implementation of the getProperty(String). - * @param basedir Implementation of the getBaseDir(). - */ - Fake( - final Function prop, - final Supplier basedir - ) { - this.prop = prop; - this.basedir = basedir; - } - - @Override - public String getProperty(final String property) { - return this.prop.apply(property); - } - - @Override - public File getBaseDir() { - return this.basedir.get(); - } - } -} diff --git a/qulice-ant/src/main/java/com/qulice/ant/QuliceTask.java b/qulice-ant/src/main/java/com/qulice/ant/QuliceTask.java deleted file mode 100644 index b2243723d..000000000 --- a/qulice-ant/src/main/java/com/qulice/ant/QuliceTask.java +++ /dev/null @@ -1,197 +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. - */ -package com.qulice.ant; - -import com.jcabi.log.Logger; -import com.qulice.checkstyle.CheckstyleValidator; -import com.qulice.pmd.PmdValidator; -import com.qulice.spi.Environment; -import com.qulice.spi.ResourceValidator; -import com.qulice.spi.ValidationException; -import com.qulice.spi.Validator; -import com.qulice.spi.Violation; -import java.io.File; -import java.util.Arrays; -import java.util.Collection; -import java.util.LinkedList; -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.Task; -import org.apache.tools.ant.types.Path; - -/** - * Ant Task for Qulice. - * - * @since 0.13 - * @checkstyle ClassDataAbstractionCouplingCheck (170 lines) - */ -public final class QuliceTask extends Task { - - /** - * Sources dirs. - */ - private Path sources; - - /** - * Classes dir (only one dir is supported). - */ - private File classes; - - /** - * Classpath dirs and files. - */ - private Path classpath; - - /** - * Set source dirs. - * @param srcdr Source dirs - */ - public void setSrcdir(final Path srcdr) { - this.sources = srcdr; - } - - /** - * Set classes dir. - * @param clssedr Classes dir - */ - public void setClassesdir(final File clssedr) { - this.classes = clssedr; - } - - /** - * Set classpath. - * @param clsspth Classpath - */ - public void setClasspath(final Path clsspth) { - this.classpath = clsspth; - } - - @Override - @SuppressWarnings({ "PMD.GuardLogStatement", "PMD.PrematureDeclaration"}) - public void execute() { - super.execute(); - final Environment env = this.environment(); - final long start = System.nanoTime(); - try { - QuliceTask.validate(env); - } catch (final ValidationException ex) { - Logger.info( - this, - "Read our quality policy: http://www.qulice.com/quality.html" - ); - throw new BuildException("Failure", ex); - } - Logger.info( - this, - "Qulice quality check completed in %[nano]s, no errors", - System.nanoTime() - start - ); - } - - /** - * Create Environment. - * @return Environment. - */ - private Environment environment() { - if (this.sources == null) { - throw new BuildException("srcdir not defined for QuliceTask"); - } - if (this.classes == null) { - throw new BuildException("classesdir not defined for QuliceTask"); - } - if (this.classpath == null) { - throw new BuildException("classpath not defined for QuliceTask"); - } - return new AntEnvironment( - new AntProject.Default(this.getProject()), - new AntPath.Default(this.sources), - this.classes, - new AntPath.Default(this.classpath) - ); - } - - /** - * Validate and throws exception if there are any problems. - * @param env Environment - * @throws ValidationException If there are any problems. - */ - private static void validate(final Environment env) - throws ValidationException { - final Collection results = new LinkedList<>(); - final Collection files = env.files("*.*"); - if (!files.isEmpty()) { - final Collection validators = - QuliceTask.validators(env); - for (final ResourceValidator validator : validators) { - results.addAll(validator.validate(files)); - } - for (final Violation result : results) { - Logger.info( - QuliceTask.class, - "%s: %s[%s]: %s (%s)", - result.validator(), - result.file(), - result.lines(), - result.message(), - result.name() - ); - } - } - for (final Validator validator : QuliceTask.validators()) { - validator.validate(env); - } - if (!results.isEmpty()) { - throw new ValidationException( - String.format("%d violations, see log above", results.size()) - ); - } - } - - /** - * Create collection of validators. - * @return Collection of validators. - */ - private static Collection validators() { - return Arrays.asList(); - } - - /** - * Create collection of validators. - * @param env Environment to use. - * @return Collection of validators. - */ - private static Collection validators( - final Environment env) { - return Arrays.asList( - new CheckstyleValidator(env), - new PmdValidator(env) - ); - } -} diff --git a/qulice-ant/src/main/java/com/qulice/ant/package-info.java b/qulice-ant/src/main/java/com/qulice/ant/package-info.java deleted file mode 100644 index d65e900da..000000000 --- a/qulice-ant/src/main/java/com/qulice/ant/package-info.java +++ /dev/null @@ -1,37 +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. - */ - -/** - * Ant task for Qulice. - * - * @since 0.13 - */ -package com.qulice.ant; diff --git a/qulice-ant/src/site/apt/index.apt.vm b/qulice-ant/src/site/apt/index.apt.vm deleted file mode 100644 index 78d2b3f61..000000000 --- a/qulice-ant/src/site/apt/index.apt.vm +++ /dev/null @@ -1,66 +0,0 @@ - ------ - Ant module - ------ - Yuriy Alevohin - ------ - 2015-01-03 - ------ - -~~ -~~ 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. -~~ -~~ - -Ant Module - - Use it like this in your Ant project: - -+-- - - - - - - - -+-- - - * License file must be in classpath. - - * Only one directory may be used as classesdir. - - That's it. Your build will fail if you have quality problems. Read - {{{../quality.html}this page}} about how you can fix them. - diff --git a/qulice-ant/src/site/site.xml b/qulice-ant/src/site/site.xml deleted file mode 100644 index edb257722..000000000 --- a/qulice-ant/src/site/site.xml +++ /dev/null @@ -1,40 +0,0 @@ - - - - - - - - - - - diff --git a/qulice-ant/src/test/java/com/qulice/ant/AntEnvironmentTest.java b/qulice-ant/src/test/java/com/qulice/ant/AntEnvironmentTest.java deleted file mode 100644 index 77b00d046..000000000 --- a/qulice-ant/src/test/java/com/qulice/ant/AntEnvironmentTest.java +++ /dev/null @@ -1,91 +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. - */ -package com.qulice.ant; - -import com.qulice.spi.Environment; -import java.io.File; -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; - -/** - * Test for AntEnvironment. - * - * @since 0.13 - * @todo #337 Implement unit tests at AntEnvironmentTest - */ -public class AntEnvironmentTest { - - /** - * AntEnvironment can build Classloader from org.apache.tools.ant.Project. - * - * It is also checked that this classloader does not depend on ant enviroment information. - * @throws Exception If something wrong happens inside - */ - @Test - @Disabled - @SuppressWarnings("PMD.UncommentedEmptyMethodBody") - public void buildsClassloader() throws Exception { - final Environment env = new AntEnvironment( - new AntProject.Fake( - ignored -> { - throw new UnsupportedOperationException(); - }, - () -> { - throw new UnsupportedOperationException(); - } - ), - new AntPath.Fake(new String[]{"/foo.java", "bar.java"}), - new File("/some/build/out"), - new AntPath.Fake(new String[]{"/libfoo", "/libbar"}) - ); - env.classloader(); - } - - /** - * AntEnvironment can return the files matching the specified pattern. - * @throws Exception If something wrong happens inside - */ - @Test - @Disabled - @SuppressWarnings("PMD.UncommentedEmptyMethodBody") - public void returnsFiles() throws Exception { - } - - /** - * AntEnvironment can exclude files. - * @throws Exception If something wrong happens inside - */ - @Test - @Disabled - @SuppressWarnings("PMD.UncommentedEmptyMethodBody") - public void excludesFiles() throws Exception { - } -} diff --git a/qulice-ant/src/test/java/com/qulice/ant/package-info.java b/qulice-ant/src/test/java/com/qulice/ant/package-info.java deleted file mode 100644 index e43207746..000000000 --- a/qulice-ant/src/test/java/com/qulice/ant/package-info.java +++ /dev/null @@ -1,37 +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. - */ - -/** - * Tests of qulice ant. - * - * @since 0.13 - */ -package com.qulice.ant; diff --git a/qulice-checkstyle/pom.xml b/qulice-checkstyle/pom.xml index 7931f00c7..d4c0f331b 100644 --- a/qulice-checkstyle/pom.xml +++ b/qulice-checkstyle/pom.xml @@ -70,23 +70,7 @@ OF THE POSSIBILITY OF SUCH DAMAGE. com.puppycrawl.tools checkstyle - 8.45.1 - - - org.abego.treelayout - org.abego.treelayout.core - - - net.sf.saxon - Saxon-HE - - - - - net.sourceforge.saxon - saxon - 9.1.0.8 - runtime + 10.9.3 commons-io diff --git a/qulice-checkstyle/src/main/java/com/qulice/checkstyle/JavadocLocationCheck.java b/qulice-checkstyle/src/main/java/com/qulice/checkstyle/JavadocLocationCheck.java index eb611442b..0cfcb77b1 100644 --- a/qulice-checkstyle/src/main/java/com/qulice/checkstyle/JavadocLocationCheck.java +++ b/qulice-checkstyle/src/main/java/com/qulice/checkstyle/JavadocLocationCheck.java @@ -67,14 +67,30 @@ public int[] getRequiredTokens() { @Override public void visitToken(final DetailAST ast) { - if (JavadocLocationCheck.isField(ast)) { - final int current = ast.getLineNo(); - final int end = JavadocLocationCheck.findCommentEnd( - this.getLines(), current - ); - if (end > JavadocLocationCheck.getCommentMinimum(ast)) { - this.report(current, end); + if (!JavadocLocationCheck.isField(ast)) { + return; + } + final String[] lines = this.getLines(); + int current = ast.getLineNo(); + boolean found = false; + final int start = current; + --current; + while (true) { + if (current <= 0) { + break; + } + final String line = lines[current - 1].trim(); + if (line.endsWith("*/")) { + found = true; + break; } + if (!line.isEmpty()) { + break; + } + --current; + } + if (found) { + this.report(start, current); } } @@ -87,6 +103,7 @@ private void report(final int current, final int end) { final int diff = current - end; if (diff > 1) { for (int pos = 1; pos < diff; pos += 1) { + System.out.printf("report=%d\n", end + pos); this.log( end + pos, "Empty line between javadoc and subject" @@ -95,45 +112,6 @@ private void report(final int current, final int end) { } } - /** - * Returns mimimum line number of the end of the comment. - * @param node Node to be checked for Java docs. - * @return Mimimum line number of the end of the comment. - */ - private static int getCommentMinimum(final DetailAST node) { - int minimum = 0; - final DetailAST parent = node.getParent(); - if (null == parent) { - if (!JavadocLocationCheck.isFirst(node)) { - final DetailAST object = node - .getPreviousSibling() - .findFirstToken(TokenTypes.OBJBLOCK); - // @checkstyle NestedIfDepth (1 line) - if (object != null) { - minimum = object.getLastChild().getLineNo(); - } - } - } else { - DetailAST previous = node.getPreviousSibling(); - if (null == previous) { - previous = parent; - } - minimum = previous.getLineNo(); - } - return minimum; - } - - /** - * Checks the specified node: is it first element or not. - * @param node Node to be checked. - * @return True if there are no any nodes before this one, else - - * {@code false}. - */ - private static boolean isFirst(final DetailAST node) { - final DetailAST previous = node.getPreviousSibling(); - return null == previous; - } - /** * Returns {@code TRUE} if a specified node is something that should have * a Javadoc, which includes classes, interface, class methods, and @@ -148,33 +126,4 @@ private static boolean isField(final DetailAST node) { } return yes; } - - /** - * Find javadoc ending comment. - * @param lines List of lines to check. - * @param start Start searching from this line number. - * @return Line number with found ending comment, or -1 if it wasn't found. - */ - private static int findCommentEnd(final String[] lines, final int start) { - return JavadocLocationCheck.findTrimmedTextUp(lines, start, "*/"); - } - - /** - * Find a text in lines, by going up. - * @param lines List of lines to check. - * @param start Start searching from this line number. - * @param text Text to find. - * @return Line number with found text, or -1 if it wasn't found. - */ - private static int findTrimmedTextUp(final String[] lines, - final int start, final String text) { - int found = -1; - for (int pos = start - 1; pos >= 0; pos -= 1) { - if (lines[pos].trim().equals(text)) { - found = pos + 1; - break; - } - } - return found; - } } diff --git a/qulice-checkstyle/src/main/java/com/qulice/checkstyle/JavadocParameterOrderCheck.java b/qulice-checkstyle/src/main/java/com/qulice/checkstyle/JavadocParameterOrderCheck.java index 9a1078b94..6c499f41b 100644 --- a/qulice-checkstyle/src/main/java/com/qulice/checkstyle/JavadocParameterOrderCheck.java +++ b/qulice-checkstyle/src/main/java/com/qulice/checkstyle/JavadocParameterOrderCheck.java @@ -106,6 +106,7 @@ public int[] getRequiredTokens() { } @Override + @SuppressWarnings("deprecation") public void visitToken(final DetailAST ast) { final FileContents contents = this.getFileContents(); final TextBlock doc = contents.getJavadocBefore(ast.getLineNo()); diff --git a/qulice-checkstyle/src/main/java/com/qulice/checkstyle/NoJavadocForOverriddenMethodsCheck.java b/qulice-checkstyle/src/main/java/com/qulice/checkstyle/NoJavadocForOverriddenMethodsCheck.java index 00b442da2..d95e28b34 100644 --- a/qulice-checkstyle/src/main/java/com/qulice/checkstyle/NoJavadocForOverriddenMethodsCheck.java +++ b/qulice-checkstyle/src/main/java/com/qulice/checkstyle/NoJavadocForOverriddenMethodsCheck.java @@ -65,6 +65,7 @@ public int[] getRequiredTokens() { } @Override + @SuppressWarnings("deprecation") public void visitToken(final DetailAST ast) { if (AnnotationUtil.containsAnnotation(ast, "Override")) { final FileContents contents = getFileContents(); diff --git a/qulice-checkstyle/src/main/java/com/qulice/checkstyle/NonStaticMethodCheck.java b/qulice-checkstyle/src/main/java/com/qulice/checkstyle/NonStaticMethodCheck.java index ef764eb33..52114ba5e 100644 --- a/qulice-checkstyle/src/main/java/com/qulice/checkstyle/NonStaticMethodCheck.java +++ b/qulice-checkstyle/src/main/java/com/qulice/checkstyle/NonStaticMethodCheck.java @@ -88,6 +88,7 @@ public int[] getRequiredTokens() { } @Override + @SuppressWarnings("deprecation") public void visitToken(final DetailAST ast) { if (this.exclude.matcher(this.getFileContents().getFileName()) .find()) { @@ -147,6 +148,7 @@ private static boolean isInAbstractOrNativeMethod(final DetailAST method) { * @param method Method to count * @return The number of semicolons in the method as an int */ + @SuppressWarnings("deprecation") private int countSemiColons(final DetailAST method) { final DetailAST openingbrace = method.findFirstToken(TokenTypes.SLIST); int count = 0; diff --git a/qulice-checkstyle/src/main/resources/com/qulice/checkstyle/checks.xml b/qulice-checkstyle/src/main/resources/com/qulice/checkstyle/checks.xml index e5d6b263f..1e4ea9455 100644 --- a/qulice-checkstyle/src/main/resources/com/qulice/checkstyle/checks.xml +++ b/qulice-checkstyle/src/main/resources/com/qulice/checkstyle/checks.xml @@ -33,72 +33,73 @@ OF THE POSSIBILITY OF SUCH DAMAGE. + Enforces English locale to be independent from the + default locale which may vary between environments. + --> - + + Checks that each Java package has a Javadoc file + used for commenting. + --> + Checks whether files end with a new line. + --> + Checks that property files contain the same keys. + --> + Maximum number of lines in any .java file is limited. + --> + TAB chars are not allowed anywhere. + --> + Trailing spaces are not allowed anywhere. + --> + Windows line endings are not allowed. + --> + Two consecutive empty lines are not allowed. + --> + JavaDoc regexp checks + --> @@ -256,16 +257,16 @@ OF THE POSSIBILITY OF SUCH DAMAGE. - + + Total number of classes that a particular class + depends on. We're increasing this value because + default "20" is too low. + --> @@ -345,8 +346,8 @@ OF THE POSSIBILITY OF SUCH DAMAGE. + Our custom checkers. + --> @@ -368,8 +369,8 @@ OF THE POSSIBILITY OF SUCH DAMAGE. + Our custom checkers. + --> diff --git a/qulice-checkstyle/src/test/java/com/qulice/checkstyle/ChecksTest.java b/qulice-checkstyle/src/test/java/com/qulice/checkstyle/ChecksTest.java index 4835bade0..32b728aa7 100644 --- a/qulice-checkstyle/src/test/java/com/qulice/checkstyle/ChecksTest.java +++ b/qulice-checkstyle/src/test/java/com/qulice/checkstyle/ChecksTest.java @@ -102,7 +102,10 @@ public void testCheckstyleTruePositive(final String dir) throws Exception { MatcherAssert.assertThat( collector.eventCount(), Matchers.describedAs( - String.format("Got more violations that expected for directory %s", dir), + String.format( + "Got more violations that expected for directory %s (%s)", + dir, collector.summary() + ), Matchers.equalTo(violations.length) ) ); diff --git a/qulice-checkstyle/src/test/resources/com/qulice/checkstyle/ChecksTest/EmptyLinesCheck/Valid.java b/qulice-checkstyle/src/test/resources/com/qulice/checkstyle/ChecksTest/EmptyLinesCheck/Valid.java index 49d73bc61..daf5075e1 100644 --- a/qulice-checkstyle/src/test/resources/com/qulice/checkstyle/ChecksTest/EmptyLinesCheck/Valid.java +++ b/qulice-checkstyle/src/test/resources/com/qulice/checkstyle/ChecksTest/EmptyLinesCheck/Valid.java @@ -18,6 +18,6 @@ public InputStream body() throws IOException { } }; } - } + }; } } diff --git a/qulice-checkstyle/src/test/resources/com/qulice/checkstyle/ChecksTest/JavadocLocationCheck/Valid.java b/qulice-checkstyle/src/test/resources/com/qulice/checkstyle/ChecksTest/JavadocLocationCheck/Valid.java index cc78eb752..ab17822ac 100644 --- a/qulice-checkstyle/src/test/resources/com/qulice/checkstyle/ChecksTest/JavadocLocationCheck/Valid.java +++ b/qulice-checkstyle/src/test/resources/com/qulice/checkstyle/ChecksTest/JavadocLocationCheck/Valid.java @@ -9,6 +9,8 @@ public final class Valid { */ private int x = 0; + private int y = 0; + /** * Public ctor. * @param num Some number @@ -46,3 +48,7 @@ interface I1 { */ private int x = 0; } + +interface I2 { + +} diff --git a/qulice-checkstyle/src/test/resources/com/qulice/checkstyle/ValidIndentation.java b/qulice-checkstyle/src/test/resources/com/qulice/checkstyle/ValidIndentation.java index 5f3dda9f7..271322230 100644 --- a/qulice-checkstyle/src/test/resources/com/qulice/checkstyle/ValidIndentation.java +++ b/qulice-checkstyle/src/test/resources/com/qulice/checkstyle/ValidIndentation.java @@ -16,6 +16,6 @@ public ValidIndentation() { new Integer( 1 ) - ) + ); } }