Skip to content
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

Issue #317: New metadata maintanence method: Fetch directly from checketyle #318

Merged
merged 1 commit into from
Aug 30, 2020

Conversation

gaurabdg
Copy link
Contributor

@gaurabdg gaurabdg commented Aug 27, 2020

#317

  • New check RecordComponentNumberCheck (to be released in 8.36) metadata is successfully loaded from checkstyle, without manual entry in rules.xml
  • The number of checks has also increased to 178 from 174.
    Screenshot_20200827_224416

@gaurabdg gaurabdg force-pushed the meta-main-integration branch from c58b53a to b2ddf41 Compare August 27, 2020 18:06
@muhlba91
Copy link
Contributor

please post a picture of the check being triggered - an analysis with code that fails the new checks.
(whenever we update the CS version and the number of checks, we need to verify they are triggering correctly upon violations in code examples)

@gaurabdg
Copy link
Contributor Author

gaurabdg commented Aug 28, 2020

please post a picture of the check being triggered - an analysis with code that fails the new checks.
(whenever we update the CS version and the number of checks, we need to verify they are triggering correctly upon violations in code examples)

But this should be done in checkstyle upgrade PR like #308 right? This is just to show that checkstyle main library integration is working.

@gaurabdg gaurabdg force-pushed the meta-main-integration branch from b2ddf41 to 29850fe Compare August 28, 2020 12:47
@romani
Copy link
Member

romani commented Aug 28, 2020

@gaurabdg , CI is red, so there is no prove that it is working.

lets use:
https://oss.sonatype.org/content/repositories/snapshots/com/puppycrawl/tools/checkstyle/8.36-SNAPSHOT/
https://github.com/checkstyle/checkstyle/wiki/How-to-use-Checkstyle-snapshot-artifacts

make CI green.
do manual testing that prove that:
plugin is can render Check metadata,
user can save default config and execute it;
user can change tokens, save and Check works as required - violations are changing;
user do have validation of user input

@romani
Copy link
Member

romani commented Aug 28, 2020

I had same problem at checkstyle/checkstyle#8768 (comment) , I fixed it in checkstyle, but looks like there is one more problem.
please reproduce it in checkstyle repo by UT.

from CI

[ERROR] Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.444 s <<< FAILURE! - in org.sonar.plugins.checkstyle.CheckstyleRulesDefinitionTest
[ERROR] test(org.sonar.plugins.checkstyle.CheckstyleRulesDefinitionTest)  Time elapsed: 0.434 s  <<< ERROR!
java.lang.IllegalArgumentException: Property 'http://javax.xml.XMLConstants/property/accessExternalDTD' is not recognized.
	at org.sonar.plugins.checkstyle.CheckstyleRulesDefinitionTest.test(CheckstyleRulesDefinitionTest.java:56)

@romani
Copy link
Member

romani commented Aug 28, 2020

I reproduced problem on my local:

✔ ~/java/github/checkstyle/sonar-checkstyle [gaurabdg/meta-main-integration L|✚ 1] 
$ file ~/.m2/repository/com/puppycrawl/tools/checkstyle/8.36-SNAPSHOT
~/.m2/repository/com/puppycrawl/tools/checkstyle/8.36-SNAPSHOT: cannot open `~/.m2/repository/com/puppycrawl/tools/checkstyle/8.36-SNAPSHOT' (No such file or directory)

✔ ~/java/github/checkstyle/sonar-checkstyle [gaurabdg/meta-main-integration L|✚ 1] 
$ git diff
diff --git a/pom.xml b/pom.xml
index 2ed7177..ad63dc4 100644
--- a/pom.xml
+++ b/pom.xml
@@ -93,7 +93,7 @@
   </ciManagement>
 
   <properties>
-    <checkstyle.version>8.36-SNAPSHOT</checkstyle.version>
+    <checkstyle.version>8.36-20200828.031041-135</checkstyle.version>
     <sonar.version>7.9</sonar.version>
     <sonar-java.version>6.0.0.20538</sonar-java.version>
     <maven.checkstyle.plugin.version>3.1.1</maven.checkstyle.plugin.version>
@@ -865,15 +865,18 @@
       </properties>
     </profile>
   </profiles>
-  <pluginRepositories>
-    <pluginRepository>
-          <id>oss.sonatype.org</id>
-          <name>oss.sonatype.org</name>
-          <url>https://oss.sonatype.org/content/repositories/snapshots</url>
-          <snapshots>
-              <enabled>true</enabled>
-              <updatePolicy>always</updatePolicy>
-            </snapshots>
-        </pluginRepository>
-  </pluginRepositories>
+
+
+  <repositories>
+    <repository>
+      <id>oss.sonatype.org</id>
+      <url>http://oss.sonatype.org/content/repositories/snapshots</url>
+      <releases>
+        <enabled>false</enabled>
+      </releases>
+      <snapshots>
+        <enabled>true</enabled>
+      </snapshots>
+    </repository>
+  </repositories>
 </project>

✔ ~/java/github/checkstyle/sonar-checkstyle [gaurabdg/meta-main-integration L|✚ 1] 
$ mvn -e clean test
[INFO] Error stacktraces are turned on.
[INFO] Scanning for projects...
[INFO] 
[INFO] -----------< com.github.checkstyle:checkstyle-sonar-plugin >------------
[INFO] Building Checkstyle SonarQube Plugin 8.36-SNAPSHOT
[INFO] ----------------------------[ sonar-plugin ]----------------------------
Downloading from oss.sonatype.org: http://oss.sonatype.org/content/repositories/snapshots/com/puppycrawl/tools/checkstyle/8.36-SNAPSHOT/checkstyle-8.36-20200828.031041-135.pom
Downloaded from oss.sonatype.org: http://oss.sonatype.org/content/repositories/snapshots/com/puppycrawl/tools/checkstyle/8.36-SNAPSHOT/checkstyle-8.36-20200828.031041-135.pom (135 kB at 92 kB/s)
Downloading from oss.sonatype.org: http://oss.sonatype.org/content/repositories/snapshots/com/puppycrawl/tools/checkstyle/8.36-SNAPSHOT/checkstyle-8.36-20200828.031041-135.jar
Downloaded from oss.sonatype.org: http://oss.sonatype.org/content/repositories/snapshots/com/puppycrawl/tools/checkstyle/8.36-SNAPSHOT/checkstyle-8.36-20200828.031041-135.jar (1.6 MB at 1.2 MB/s)
[INFO] 
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ checkstyle-sonar-plugin ---
[INFO] Deleting /home/rivanov/java/github/checkstyle/sonar-checkstyle/target
[INFO] 
[INFO] --- maven-enforcer-plugin:3.0.0-M3:enforce (enforce-jdk-maven-versions) @ checkstyle-sonar-plugin ---
[INFO] 
[INFO] --- sonar-packaging-maven-plugin:1.17:check (default-check) @ checkstyle-sonar-plugin ---
[INFO] 
[INFO] --- maven-resources-plugin:3.2.0:resources (default-resources) @ checkstyle-sonar-plugin ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Using 'UTF-8' encoding to copy filtered properties files.
[INFO] Copying 1 resource
[INFO] Copying 180 resources
[INFO] The encoding used to copy filtered properties files have not been set. This means that the same encoding will be used to copy filtered properties files as when copying other filtered resources. This might not be what you want! Run your build with --debug to see which files might be affected. Read more at https://maven.apache.org/plugins/maven-resources-plugin/examples/filtering-properties-files.html
[INFO] 
[INFO] --- maven-compiler-plugin:3.6.0:compile (default-compile) @ checkstyle-sonar-plugin ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 18 source files to /home/rivanov/java/github/checkstyle/sonar-checkstyle/target/classes
[INFO] /home/rivanov/java/github/checkstyle/sonar-checkstyle/src/main/java/org/sonar/plugins/checkstyle/CheckstyleProfileImporter.java: Some input files use or override a deprecated API.
[INFO] /home/rivanov/java/github/checkstyle/sonar-checkstyle/src/main/java/org/sonar/plugins/checkstyle/CheckstyleProfileImporter.java: Recompile with -Xlint:deprecation for details.
[INFO] 
[INFO] --- build-helper-maven-plugin:3.0.0:add-test-source (add-test-source) @ checkstyle-sonar-plugin ---
[INFO] Test Source directory: /home/rivanov/java/github/checkstyle/sonar-checkstyle/src/it/java added.
[INFO] 
[INFO] --- maven-resources-plugin:3.2.0:testResources (default-testResources) @ checkstyle-sonar-plugin ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Using 'UTF-8' encoding to copy filtered properties files.
[INFO] Copying 22 resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.6.0:testCompile (default-testCompile) @ checkstyle-sonar-plugin ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 18 source files to /home/rivanov/java/github/checkstyle/sonar-checkstyle/target/test-classes
[INFO] /home/rivanov/java/github/checkstyle/sonar-checkstyle/src/test/java/org/sonar/plugins/checkstyle/CheckstyleExecutorTest.java: Some input files use or override a deprecated API.
[INFO] /home/rivanov/java/github/checkstyle/sonar-checkstyle/src/test/java/org/sonar/plugins/checkstyle/CheckstyleExecutorTest.java: Recompile with -Xlint:deprecation for details.
[INFO] 
[INFO] --- jacoco-maven-plugin:0.8.5:instrument (default-instrument) @ checkstyle-sonar-plugin ---
[INFO] 
[INFO] --- maven-surefire-plugin:2.22.1:test (default-test) @ checkstyle-sonar-plugin ---
[INFO] Surefire report directory: /home/rivanov/java/github/checkstyle/sonar-checkstyle/target/surefire-reports
[INFO] 
[INFO] -------------------------------------------------------
[INFO]  T E S T S
[INFO] -------------------------------------------------------
[INFO] Running org.sonar.plugins.checkstyle.CheckstyleSeverityUtilsTest
[INFO] Tests run: 5, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.207 s - in org.sonar.plugins.checkstyle.CheckstyleSeverityUtilsTest
[INFO] Running org.sonar.plugins.checkstyle.CheckstyleVersionTest
[INFO] Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.001 s - in org.sonar.plugins.checkstyle.CheckstyleVersionTest
[INFO] Running org.sonar.plugins.checkstyle.CheckstyleExecutorTest
[INFO] Tests run: 7, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.607 s - in org.sonar.plugins.checkstyle.CheckstyleExecutorTest
[INFO] Running org.sonar.plugins.checkstyle.CheckstyleAuditListenerTest
[INFO] Tests run: 7, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.126 s - in org.sonar.plugins.checkstyle.CheckstyleAuditListenerTest
[INFO] Running org.sonar.plugins.checkstyle.CheckstylePluginTest
[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.002 s - in org.sonar.plugins.checkstyle.CheckstylePluginTest
[INFO] Running org.sonar.plugins.checkstyle.metadata.CheckstyleMetadataTest
[ERROR] Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.158 s <<< FAILURE! - in org.sonar.plugins.checkstyle.metadata.CheckstyleMetadataTest
[ERROR] org.sonar.plugins.checkstyle.metadata.CheckstyleMetadataTest  Time elapsed: 0.158 s  <<< ERROR!
java.lang.IllegalArgumentException: Property 'http://javax.xml.XMLConstants/property/accessExternalDTD' is not recognized.
	at org.sonar.plugins.checkstyle.metadata.CheckstyleMetadataTest.getPreparedRepository(CheckstyleMetadataTest.java:49)

[INFO] Running org.sonar.plugins.checkstyle.internal.ChecksTest
[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.448 s - in org.sonar.plugins.checkstyle.internal.ChecksTest
[INFO] Running org.sonar.plugins.checkstyle.CheckstyleProfileImporterTest
[INFO] Tests run: 9, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.023 s - in org.sonar.plugins.checkstyle.CheckstyleProfileImporterTest
[INFO] Running org.sonar.plugins.checkstyle.CheckstyleSensorTest
[INFO] Tests run: 3, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.007 s - in org.sonar.plugins.checkstyle.CheckstyleSensorTest
[INFO] Running org.sonar.plugins.checkstyle.CheckstyleConstantsTest
[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0 s - in org.sonar.plugins.checkstyle.CheckstyleConstantsTest
[INFO] Running org.sonar.plugins.checkstyle.CheckstyleConfigurationTest
[INFO] Tests run: 4, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.041 s - in org.sonar.plugins.checkstyle.CheckstyleConfigurationTest
[INFO] Running org.sonar.plugins.checkstyle.CheckstyleProfileExporterTest
[INFO] Tests run: 11, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.071 s - in org.sonar.plugins.checkstyle.CheckstyleProfileExporterTest
[INFO] Running org.sonar.plugins.checkstyle.CheckstyleRulesDefinitionTest
[ERROR] Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.042 s <<< FAILURE! - in org.sonar.plugins.checkstyle.CheckstyleRulesDefinitionTest
[ERROR] test(org.sonar.plugins.checkstyle.CheckstyleRulesDefinitionTest)  Time elapsed: 0.041 s  <<< ERROR!
java.lang.IllegalArgumentException: Property 'http://javax.xml.XMLConstants/property/accessExternalDTD' is not recognized.
	at org.sonar.plugins.checkstyle.CheckstyleRulesDefinitionTest.test(CheckstyleRulesDefinitionTest.java:56)

[INFO] 
[INFO] Results:
[INFO] 
[ERROR] Errors: 
[ERROR]   CheckstyleRulesDefinitionTest.test:56 » IllegalArgument Property 'http://javax...
[ERROR]   CheckstyleMetadataTest.getPreparedRepository:49 » IllegalArgument Property 'ht...
[INFO] 
[ERROR] Tests run: 53, Failures: 0, Errors: 2, Skipped: 0
[INFO] 
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  8.535 s
[INFO] Finished at: 2020-08-28T06:54:50-07:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.22.1:test (default-test) on project checkstyle-sonar-plugin: There are test failures.
[ERROR] 
[ERROR] Please refer to /home/rivanov/java/github/checkstyle/sonar-checkstyle/target/surefire-reports for the individual test results.
[ERROR] Please refer to dump files (if any exist) [date].dump, [date]-jvmRun[N].dump and [date].dumpstream.
[ERROR] -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.22.1:test (default-test) on project checkstyle-sonar-plugin: There are test failures.

Please refer to /home/rivanov/java/github/checkstyle/sonar-checkstyle/target/surefire-reports for the individual test results.
Please refer to dump files (if any exist) [date].dump, [date]-jvmRun[N].dump and [date].dumpstream.
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:956)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:288)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:192)
    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:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
Caused by: org.apache.maven.plugin.MojoFailureException: There are test failures.

Please refer to /home/rivanov/java/github/checkstyle/sonar-checkstyle/target/surefire-reports for the individual test results.
Please refer to dump files (if any exist) [date].dump, [date]-jvmRun[N].dump and [date].dumpstream.
    at org.apache.maven.plugin.surefire.SurefireHelper.throwException (SurefireHelper.java:289)
    at org.apache.maven.plugin.surefire.SurefireHelper.reportExecution (SurefireHelper.java:161)
    at org.apache.maven.plugin.surefire.SurefirePlugin.handleSummary (SurefirePlugin.java:364)
    at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeAfterPreconditionsChecked (AbstractSurefireMojo.java:1041)
    at org.apache.maven.plugin.surefire.AbstractSurefireMojo.execute (AbstractSurefireMojo.java:857)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:956)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:288)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:192)
    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:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
[ERROR] 
[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

@romani
Copy link
Member

romani commented Aug 28, 2020

but it works fine with version <checkstyle.version>8.36-20200827.222806-133</checkstyle.version>
it is build before I did fixes raised sonar about security checkstyle/checkstyle#8768 (comment) .

@romani
Copy link
Member

romani commented Aug 28, 2020

full stracktrace:

java.lang.IllegalArgumentException: Property 'http://javax.xml.XMLConstants/property/accessExternalDTD' is not recognized.

	at org.apache.xerces.jaxp.DocumentBuilderFactoryImpl.setAttribute(Unknown Source)
	at com.puppycrawl.tools.checkstyle.meta.XmlMetaReader.read(XmlMetaReader.java:124)
	at com.puppycrawl.tools.checkstyle.meta.XmlMetaReader.readAllModulesIncludingThirdPartyIfAny(XmlMetaReader.java:98)
	at org.sonar.plugins.checkstyle.metadata.CheckstyleMetadata.<init>(CheckstyleMetadata.java:58)
	at org.sonar.plugins.checkstyle.CheckstyleRulesDefinition.define(CheckstyleRulesDefinition.java:66)
	at org.sonar.plugins.checkstyle.CheckstyleRulesDefinitionTest.test(CheckstyleRulesDefinitionTest.java:56)
	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.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
	at org.junit.rules.ExpectedException$ExpectedExceptionStatement.evaluate(ExpectedException.java:239)
	at org.junit.rules.RunRules.evaluate(RunRules.java:20)
	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
	at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
	at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
	at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:33)
	at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:230)
	at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:58)

caused by
https://github.com/checkstyle/checkstyle/blob/521198d66dfc15b4b518cc011941b86ad3ddb8ea/src/main/java/com/puppycrawl/tools/checkstyle/meta/XmlMetaReader.java#L121-L125
It was not detected in Checkstyle repo because there is no UT that reads xml files.....
I reverted my fix from Checkstyle repo ... snapshot jar is deployed

@gaurabdg gaurabdg changed the title Issue #317: New metadata maintanence method: Fetch directly from chec… Issue #317: New metadata maintanence method: Fetch directly from checketyle Aug 28, 2020
@gaurabdg gaurabdg force-pushed the meta-main-integration branch 2 times, most recently from e1034b5 to 7f09ab8 Compare August 28, 2020 21:19
@gaurabdg
Copy link
Contributor Author

Manual Tests:
@romani @muhlba91 I did the best I can to prove thorugh screenshots, you can pull these changes and test yourself too.

plugin is can render Check metadata,

Shown in PR description

user can save default config and execute it;

new "test" profile created to test default config:
Screenshot_20200829_161107
success on building:
Screenshot_20200829_161316

user can change tokens, save and Check works as required - violations are changing;

Activating EmptyBlock with LITERAL_IFonly
Screenshot_20200829_162305
Removing LITERAL_IF and using LITERAL_ELSE only
Screenshot_20200829_163232
Screenshot_20200829_163311

user do have validation of user input

Screenshot_20200829_162022

@romani
Copy link
Member

romani commented Aug 29, 2020

@gaurabdg , please fix CI - https://travis-ci.org/github/checkstyle/sonar-checkstyle/jobs/722154861#L319

[INFO] Running org.sonar.plugins.checkstyle.CheckstyleRulesDefinitionTest

[ERROR] Tests run: 1, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 1.61 s 
<<< FAILURE! - in org.sonar.plugins.checkstyle.CheckstyleRulesDefinitionTest

[ERROR] test(org.sonar.plugins.checkstyle.CheckstyleRulesDefinitionTest) 
 Time elapsed: 1.61 s 
 <<< FAILURE!

java.lang.AssertionError: expected size:<179> but was:<178> for 
<[[repository=checkstyle, 
key=com.puppycrawl.tools.checkstyle.checks.metrics.CyclomaticComplexityCheck], [repository=checkstyle, 

@gaurabdg gaurabdg force-pushed the meta-main-integration branch from 7f09ab8 to 318d297 Compare August 29, 2020 21:09
Copy link
Member

@romani romani left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

items:

pom.xml Outdated Show resolved Hide resolved
@gaurabdg gaurabdg force-pushed the meta-main-integration branch from 055b277 to a44068f Compare August 29, 2020 23:40
Copy link
Member

@romani romani left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

item:

@@ -118,6 +269,10 @@ private static void validateSonarRules(Document document, Set<Class<?>> modules)

final String key = rule.getAttributes().getNamedItem("key").getTextContent();

if (!PRE_CHECKSTYLE_8_36_MODULES.contains(key)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please filter out all modules that from version 8.36 and above from final Set<Class<?>> modules = CheckUtil.getCheckstyleModules();

so you will need to filter out ones only.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

moved to #323

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, it wouldnt help.

            Assert.assertNotNull("Unknown class found in sonar rules"
                    + " (" + RULES_PATH + ")" + " :" + key, module);

This would get executed for checks which would be filtered out, but rules.xml will still contain it, so we will end up having additional checks.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@muhlba91, please take a look

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gaurabdg @romani i only see a "clean code" benefit here but not a performance related one as we are using a HashSet, which has lookups of O(1) in this case.

@gaurabdg what i'd rather see is a short comment wherever this filter is used why exactly we need it at this place.

i believe #322 and #321 are of high importance and should be fixed now. next up probably #324 and this one can be looked at last.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@muhlba91 #322 is fixed by #325
Yes, I will add comments.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities (and Security Hotspot 0 Security Hotspots to review)
Code Smell A 0 Code Smells

100.0% 100.0% Coverage
0.0% 0.0% Duplication

@romani
Copy link
Member

romani commented Aug 30, 2020

One bug that could be done after this PR is merged - #322

Copy link
Member

@romani romani left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

update is small
as update to 8.36 must be done, I am merging this PR we can improve further in other PR/issues

@romani romani merged commit 14a801e into checkstyle:master Aug 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants