New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

problem with usage of third-party Check libraries and checkstyle 7.8 #4387

Closed
romani opened this Issue May 29, 2017 · 4 comments

Comments

Projects
None yet
2 participants
@romani
Member

romani commented May 29, 2017

failed builds (almost all ):
https://travis-ci.org/sevntu-checkstyle/checkstyle-samples/builds/237027197#L3680
https://travis-ci.org/sevntu-checkstyle/sevntu.checkstyle/jobs/237027232#L720
https://travis-ci.org/checkstyle/checkstyle/jobs/237027341#L495

~/java/github/sevntu-checkstyle/checkstyle-samples/maven-project [master|✔] 
21:13 $ mvn -X checkstyle:check

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-checkstyle-plugin:2.17:check (default-cli) on project maven-project: Execution default-cli of goal org.apache.maven.plugins:maven-checkstyle-plugin:2.17:check failed: Duplicate key com.github.sevntu.checkstyle.checks.design.HideUtilityClassConstructorCheck -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-checkstyle-plugin:2.17:check (default-cli) on project maven-project: Execution default-cli of goal org.apache.maven.plugins:maven-checkstyle-plugin:2.17:check failed: Duplicate key com.github.sevntu.checkstyle.checks.design.HideUtilityClassConstructorCheck
	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:212)
	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
	at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
	at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
	at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
	at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
	at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
	at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
	at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
	at org.apache.maven.cli.MavenCli.execute(MavenCli.java:863)
	at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
	at org.apache.maven.cli.MavenCli.main(MavenCli.java:199)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
	at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
	at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
	at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: org.apache.maven.plugin.PluginExecutionException: Execution default-cli of goal org.apache.maven.plugins:maven-checkstyle-plugin:2.17:check failed: Duplicate key com.github.sevntu.checkstyle.checks.design.HideUtilityClassConstructorCheck
	at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:145)
	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207)
	... 20 more
Caused by: java.lang.IllegalStateException: Duplicate key com.github.sevntu.checkstyle.checks.design.HideUtilityClassConstructorCheck
	at java.util.stream.Collectors.lambda$throwingMerger$0(Collectors.java:133)
	at java.util.HashMap.merge(HashMap.java:1253)
	at java.util.stream.Collectors.lambda$toMap$58(Collectors.java:1320)
	at java.util.stream.ReduceOps$3ReducingSink.accept(ReduceOps.java:169)
	at java.util.HashMap$KeySpliterator.forEachRemaining(HashMap.java:1548)
	at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481)
	at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)
	at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708)
	at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
	at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:499)
	at com.puppycrawl.tools.checkstyle.PackageObjectFactory.generateThirdPartyNameToFullModuleName(PackageObjectFactory.java:203)
	at com.puppycrawl.tools.checkstyle.PackageObjectFactory.createModule(PackageObjectFactory.java:146)
	at com.puppycrawl.tools.checkstyle.TreeWalker.setupChild(TreeWalker.java:152)
	at com.puppycrawl.tools.checkstyle.api.AutomaticBean.configure(AutomaticBean.java:171)
	at com.puppycrawl.tools.checkstyle.Checker.setupChild(Checker.java:452)
	at com.puppycrawl.tools.checkstyle.api.AutomaticBean.configure(AutomaticBean.java:171)
	at org.apache.maven.plugin.checkstyle.exec.DefaultCheckstyleExecutor.executeCheckstyle(DefaultCheckstyleExecutor.java:218)
	at org.apache.maven.plugin.checkstyle.CheckstyleViolationCheckMojo.execute(CheckstyleViolationCheckMojo.java:538)
	at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
	... 21 more
[ERROR] 
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginExecutionException

@romani

This comment has been minimized.

Show comment
Hide comment
@romani

romani May 29, 2017

Member

@Luolc , please take a look ASAP.
I will take a look after release is completed.

Member

romani commented May 29, 2017

@Luolc , please take a look ASAP.
I will take a look after release is completed.

Luolc added a commit to Luolc/checkstyle that referenced this issue May 29, 2017

Luolc added a commit to Luolc/checkstyle that referenced this issue May 29, 2017

Luolc added a commit to Luolc/checkstyle that referenced this issue May 30, 2017

Luolc added a commit to Luolc/checkstyle that referenced this issue May 31, 2017

@rnveach

This comment has been minimized.

Show comment
Hide comment
@rnveach

rnveach May 31, 2017

Member

https://travis-ci.org/sevntu-checkstyle/sevntu.checkstyle/jobs/237027232#L720

@romani Why didn't our CI's catch something like this?
It looks like we should have a new CI that does an integration test with sevntu to confirm no exceptions occur.
Something similar to https://github.com/checkstyle/checkstyle/blob/master/wercker.yml#L40-L55 .

Member

rnveach commented May 31, 2017

https://travis-ci.org/sevntu-checkstyle/sevntu.checkstyle/jobs/237027232#L720

@romani Why didn't our CI's catch something like this?
It looks like we should have a new CI that does an integration test with sevntu to confirm no exceptions occur.
Something similar to https://github.com/checkstyle/checkstyle/blob/master/wercker.yml#L40-L55 .

@romani

This comment has been minimized.

Show comment
Hide comment
@romani

romani May 31, 2017

Member

The reason is we did have a time to create complete protection from all mistakes, and we will never have.

We need to extend CI with new level of testing now, in scope of this issue.

Member

romani commented May 31, 2017

The reason is we did have a time to create complete protection from all mistakes, and we will never have.

We need to extend CI with new level of testing now, in scope of this issue.

rnveach added a commit to rnveach/checkstyle that referenced this issue Jun 1, 2017

rnveach added a commit to rnveach/checkstyle that referenced this issue Jun 1, 2017

Luolc added a commit to Luolc/checkstyle that referenced this issue Jun 1, 2017

Luolc added a commit to Luolc/checkstyle that referenced this issue Jun 1, 2017

rnveach added a commit to rnveach/checkstyle that referenced this issue Jun 1, 2017

romani added a commit that referenced this issue Jun 3, 2017

romani added a commit that referenced this issue Jun 3, 2017

Revert "minor: remove problematic Check to unblock CI failure states,…
… this commit will be revered after fix for #4387"

This reverts commit e88cdd4.

romani added a commit that referenced this issue Jun 3, 2017

romani added a commit that referenced this issue Jun 3, 2017

@romani

This comment has been minimized.

Show comment
Hide comment
@romani

romani Jun 3, 2017

Member

I did a fix

My testing to prove that fully qualified names of thirdparty checks will work:

$ mvn verify -DskipTests -DskipITs
....
[INFO] --- maven-checkstyle-plugin:2.17:check (sevntu-checkstyle-check) @ checkstyle ---
[INFO] There is 1 error reported by Checkstyle 7.9-SNAPSHOT with /home/rivanov/java/github/checkstyle/checkstyle/config/checkstyle_sevntu_checks.xml ruleset.
[ERROR] src/test/java/com/puppycrawl/tools/checkstyle/internal/CheckUtil.java:[49,1] (extension) HideUtilityClassConstructor: Utility classes should not have a public or default constructor.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 20.055 s
[INFO] Finished at: 2017-06-03T10:57:49-07:00
[INFO] Final Memory: 51M/973M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-checkstyle-plugin:2.17:check (sevntu-checkstyle-check) on project checkstyle: You have 1 Checkstyle violation. -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
✘-1 ~/java/github/checkstyle/checkstyle [master|✚ 5] 

$ git diff
diff --git a/config/checkstyle_checks.xml b/config/checkstyle_checks.xml
index 80580ed..452bcf4 100644
--- a/config/checkstyle_checks.xml
+++ b/config/checkstyle_checks.xml
@@ -208,7 +208,7 @@
       <property name="ignoredAnnotations" value="Override, Test, Before, After, BeforeClass, AfterClass"/>
     </module>
     <module name="FinalClass"/>
-    <module name="HideUtilityClassConstructor"/>
+    <!--<module name="HideUtilityClassConstructor"/>-->
     <module name="InnerTypeLast"/>
     <module name="InterfaceIsType"/>
     <module name="MutableException"/>
diff --git a/config/checkstyle_sevntu_checks.xml b/config/checkstyle_sevntu_checks.xml
index 292fde8..75e592c 100644
--- a/config/checkstyle_sevntu_checks.xml
+++ b/config/checkstyle_sevntu_checks.xml
@@ -190,7 +190,7 @@
         <module name="NumericLiteralNeedsUnderscoreCheck"/>
         <module name="UniformEnumConstantNameCheck" />
         <module name="ForbidAnnotationElementValueCheck" />
-        <module name="HideUtilityClassConstructorCheck" />
+        <module name="com.github.sevntu.checkstyle.checks.design.HideUtilityClassConstructorCheck" />
         <module name="AvoidModifiersForTypesCheck">
           <property name="forbiddenClassesRegexpProtected" value="Logger"/>
           <property name="forbiddenClassesRegexpPublic" value="Logger"/>
diff --git a/pom.xml b/pom.xml
index dfe9409..9ff3b72 100644
--- a/pom.xml
+++ b/pom.xml
@@ -204,7 +204,7 @@
     <maven.jacoco.plugin.version>0.7.9</maven.jacoco.plugin.version>
     <maven.checkstyle.plugin.version>2.17</maven.checkstyle.plugin.version>
     <maven.sevntu.checkstyle.plugin.version>1.24.0</maven.sevntu.checkstyle.plugin.version>
-    <maven.sevntu-checkstyle-check.checkstyle.version>7.8</maven.sevntu-checkstyle-check.checkstyle.version>
+    <maven.sevntu-checkstyle-check.checkstyle.version>7.9-SNAPSHOT</maven.sevntu-checkstyle-check.checkstyle.version>
     <maven.versions.plugin.version>2.3</maven.versions.plugin.version>
     <java.version>1.8</java.version>
     <tools.jar.version>${java.version}.0</tools.jar.version>
diff --git a/src/main/java/com/puppycrawl/tools/checkstyle/PackageObjectFactory.java b/src/main/java/com/puppycrawl/tools/checkstyle/PackageObjectFactory.java
index 3646178..304a5dc 100644
--- a/src/main/java/com/puppycrawl/tools/checkstyle/PackageObjectFactory.java
+++ b/src/main/java/com/puppycrawl/tools/checkstyle/PackageObjectFactory.java
@@ -200,7 +200,8 @@ public class PackageObjectFactory implements ModuleFactory {
         Map<String, String> returnValue;
         try {
             returnValue = ModuleReflectionUtils.getCheckstyleModules(packages, loader).stream()
-                    .collect(Collectors.toMap(Class::getSimpleName, Class::getCanonicalName));
+                .filter(clazz -> !NAME_TO_FULL_MODULE_NAME.keySet().contains(clazz.getSimpleName()))
+                .collect(Collectors.toMap(Class::getSimpleName, Class::getCanonicalName));
         }
         catch (IOException ignore) {
             returnValue = new HashMap<>();
diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/internal/CheckUtil.java b/src/test/java/com/puppycrawl/tools/checkstyle/internal/CheckUtil.java
index 20652bf..72a0e2d 100644
--- a/src/test/java/com/puppycrawl/tools/checkstyle/internal/CheckUtil.java
+++ b/src/test/java/com/puppycrawl/tools/checkstyle/internal/CheckUtil.java
@@ -47,8 +47,8 @@ import com.puppycrawl.tools.checkstyle.utils.ModuleReflectionUtils;
 import com.puppycrawl.tools.checkstyle.utils.TokenUtils;
 
 public final class CheckUtil {
-    private CheckUtil() {
-    }
+    /*private CheckUtil() {
+    }*/
 
     public static Set<String> getConfigCheckStyleModules() {
         return getCheckStyleModulesReferencedInConfig("config/checkstyle_checks.xml");

New issue: #4414

Member

romani commented Jun 3, 2017

I did a fix

My testing to prove that fully qualified names of thirdparty checks will work:

$ mvn verify -DskipTests -DskipITs
....
[INFO] --- maven-checkstyle-plugin:2.17:check (sevntu-checkstyle-check) @ checkstyle ---
[INFO] There is 1 error reported by Checkstyle 7.9-SNAPSHOT with /home/rivanov/java/github/checkstyle/checkstyle/config/checkstyle_sevntu_checks.xml ruleset.
[ERROR] src/test/java/com/puppycrawl/tools/checkstyle/internal/CheckUtil.java:[49,1] (extension) HideUtilityClassConstructor: Utility classes should not have a public or default constructor.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 20.055 s
[INFO] Finished at: 2017-06-03T10:57:49-07:00
[INFO] Final Memory: 51M/973M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-checkstyle-plugin:2.17:check (sevntu-checkstyle-check) on project checkstyle: You have 1 Checkstyle violation. -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
✘-1 ~/java/github/checkstyle/checkstyle [master|✚ 5] 

$ git diff
diff --git a/config/checkstyle_checks.xml b/config/checkstyle_checks.xml
index 80580ed..452bcf4 100644
--- a/config/checkstyle_checks.xml
+++ b/config/checkstyle_checks.xml
@@ -208,7 +208,7 @@
       <property name="ignoredAnnotations" value="Override, Test, Before, After, BeforeClass, AfterClass"/>
     </module>
     <module name="FinalClass"/>
-    <module name="HideUtilityClassConstructor"/>
+    <!--<module name="HideUtilityClassConstructor"/>-->
     <module name="InnerTypeLast"/>
     <module name="InterfaceIsType"/>
     <module name="MutableException"/>
diff --git a/config/checkstyle_sevntu_checks.xml b/config/checkstyle_sevntu_checks.xml
index 292fde8..75e592c 100644
--- a/config/checkstyle_sevntu_checks.xml
+++ b/config/checkstyle_sevntu_checks.xml
@@ -190,7 +190,7 @@
         <module name="NumericLiteralNeedsUnderscoreCheck"/>
         <module name="UniformEnumConstantNameCheck" />
         <module name="ForbidAnnotationElementValueCheck" />
-        <module name="HideUtilityClassConstructorCheck" />
+        <module name="com.github.sevntu.checkstyle.checks.design.HideUtilityClassConstructorCheck" />
         <module name="AvoidModifiersForTypesCheck">
           <property name="forbiddenClassesRegexpProtected" value="Logger"/>
           <property name="forbiddenClassesRegexpPublic" value="Logger"/>
diff --git a/pom.xml b/pom.xml
index dfe9409..9ff3b72 100644
--- a/pom.xml
+++ b/pom.xml
@@ -204,7 +204,7 @@
     <maven.jacoco.plugin.version>0.7.9</maven.jacoco.plugin.version>
     <maven.checkstyle.plugin.version>2.17</maven.checkstyle.plugin.version>
     <maven.sevntu.checkstyle.plugin.version>1.24.0</maven.sevntu.checkstyle.plugin.version>
-    <maven.sevntu-checkstyle-check.checkstyle.version>7.8</maven.sevntu-checkstyle-check.checkstyle.version>
+    <maven.sevntu-checkstyle-check.checkstyle.version>7.9-SNAPSHOT</maven.sevntu-checkstyle-check.checkstyle.version>
     <maven.versions.plugin.version>2.3</maven.versions.plugin.version>
     <java.version>1.8</java.version>
     <tools.jar.version>${java.version}.0</tools.jar.version>
diff --git a/src/main/java/com/puppycrawl/tools/checkstyle/PackageObjectFactory.java b/src/main/java/com/puppycrawl/tools/checkstyle/PackageObjectFactory.java
index 3646178..304a5dc 100644
--- a/src/main/java/com/puppycrawl/tools/checkstyle/PackageObjectFactory.java
+++ b/src/main/java/com/puppycrawl/tools/checkstyle/PackageObjectFactory.java
@@ -200,7 +200,8 @@ public class PackageObjectFactory implements ModuleFactory {
         Map<String, String> returnValue;
         try {
             returnValue = ModuleReflectionUtils.getCheckstyleModules(packages, loader).stream()
-                    .collect(Collectors.toMap(Class::getSimpleName, Class::getCanonicalName));
+                .filter(clazz -> !NAME_TO_FULL_MODULE_NAME.keySet().contains(clazz.getSimpleName()))
+                .collect(Collectors.toMap(Class::getSimpleName, Class::getCanonicalName));
         }
         catch (IOException ignore) {
             returnValue = new HashMap<>();
diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/internal/CheckUtil.java b/src/test/java/com/puppycrawl/tools/checkstyle/internal/CheckUtil.java
index 20652bf..72a0e2d 100644
--- a/src/test/java/com/puppycrawl/tools/checkstyle/internal/CheckUtil.java
+++ b/src/test/java/com/puppycrawl/tools/checkstyle/internal/CheckUtil.java
@@ -47,8 +47,8 @@ import com.puppycrawl.tools.checkstyle.utils.ModuleReflectionUtils;
 import com.puppycrawl.tools.checkstyle.utils.TokenUtils;
 
 public final class CheckUtil {
-    private CheckUtil() {
-    }
+    /*private CheckUtil() {
+    }*/
 
     public static Set<String> getConfigCheckStyleModules() {
         return getCheckStyleModulesReferencedInConfig("config/checkstyle_checks.xml");

New issue: #4414

@romani romani closed this Jun 3, 2017

@romani romani added this to the 8.0 milestone Jun 3, 2017

@romani romani added the bug label Jun 3, 2017

romani added a commit that referenced this issue Jun 3, 2017

Issue #4387: skip checkstyle plugin execution during release as it de…
…pends on old version and could cause problems
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment