Checkstyle Sonar plugin needs to be updated

114 views
Skip to first unread message

rd....@gmail.com

unread,
Jun 24, 2015, 8:41:26 AM6/24/15
to sona...@googlegroups.com
Hi there,

I met the following problem when tried to turn on one of the existing Checkstyle checks in Sonar: https://github.com/sevntu-checkstyle/sevntu.checkstyle/issues/366

The latest version of Checkstyle plugin for Sonar v2.3 uses Checkstyle v6.4.1 (http://docs.sonarqube.org/display/PLUG/Checkstyle+Plugin) which leads to the aforementioned problem. That is because the backward compatibility was broken in Checkstyle v6.5 (http://checkstyle.sourceforge.net/releasenotes.html#Release_6.5).

So, Checkstyle Sonar plugin needs to be updated to use the latest version of Checkstyle dependency.

Thanks,
Ruslan Diachenko

Nicolas Peru

unread,
Jun 24, 2015, 8:53:23 AM6/24/15
to rd....@gmail.com, sona...@googlegroups.com
Hi, 

Thanks for notification, this is already in our backlog : http://jira.sonarsource.com/browse/SONARCHKST-25 

Cheers,

Nicolas PERU | SonarSource
Senior Developer
http://sonarsource.com


--
You received this message because you are subscribed to the Google Groups "SonarQube" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sonarqube+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sonarqube/a0d7af0d-31f0-4168-baf5-2a99d3670d4b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

rd....@gmail.com

unread,
Jun 25, 2015, 11:15:03 AM6/25/15
to sona...@googlegroups.com, rd....@gmail.com
Hi,

Guava v15.0 is enough to compile Checkstyle and save compatibility with current SQ core API.

The following steps allowed me to solve my problem:

1. Build Checkstyle with guava v15.0

    Edit checkstyle/pom.xml:
    
     <groupId>com.google.guava</groupId>
       <artifactId>guava</artifactId>
-      <version>18.0</version>
+      <version>15.0</version>
     </dependency>

    Compile and install new Checkstyle v6.8-SNAPSHOT:

$ mvn install


2. Build sonar-checkstyle plugin with Checkstyle v6.8-SNAPSHOT


    Edit sonar-checkstyle/pom.xml:

-    <checkstyle.version>6.4.1</checkstyle.version>
+    <checkstyle.version>6.8-SNAPSHOT</checkstyle.version>


3. Quick fix for org.sonar.plugins.checkstyle.CheckstyleProfileExporterTest

$ mvn test

Tests run: 6, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 0.364 sec <<< FAILURE! - in org.sonar.plugins.checkstyle.CheckstyleProfileExporterTest
singleCheckstyleRulesToExport(org.sonar.plugins.checkstyle.CheckstyleProfileExporterTest)  Time elapsed: 0.035 sec  <<< FAILURE!
java.lang.AssertionError: Diff: org.custommonkey.xmlunit.Diff
[different] Expected attribute value 'LineLength' but was 'LocalFinalVariableName' - comparing <module name="LineLength"...> at /module[1]/module[4]/module[3]/@name to <module name="LocalFinalVariableName"...> at /module[1]/module[4]/module[3]/@name

XML: <?xml version="1.0" encoding="UTF-8"?><!-- Generated by Sonar --><module name="Checker"><module name="SuppressionCommentFilter" /><module name="SuppressWarningsFilter" /><module name="JavadocPackage"><property name="severity" value="warning"/></module><module name="TreeWalker"><module name="FileContentsHolder"/> <module name="SuppressWarningsHolder"/> <module name="LineLength"><property name="severity" value="error"/></module><module name="LocalFinalVariableName"><property name="severity" value="info"/></module></module></module>
at org.junit.Assert.fail(Assert.java:88)
at org.junit.Assert.assertTrue(Assert.java:41)
at org.sonar.plugins.checkstyle.CheckstyleTestUtils.assertSimilarXml(CheckstyleTestUtils.java:54)
at org.sonar.plugins.checkstyle.CheckstyleTestUtils.assertSimilarXmlWithResource(CheckstyleTestUtils.java:58)
at org.sonar.plugins.checkstyle.CheckstyleProfileExporterTest.singleCheckstyleRulesToExport(CheckstyleProfileExporterTest.java:87)

    Edit src/test/resources/org/sonar/plugins/checkstyle/CheckstyleProfileExporterTest/singleCheckstyleRulesToExport.xml file:

--- a/src/test/resources/org/sonar/plugins/checkstyle/CheckstyleProfileExporterTest/singleCheckstyleRulesToExport.xml
+++ b/src/test/resources/org/sonar/plugins/checkstyle/CheckstyleProfileExporterTest/singleCheckstyleRulesToExport.xml
@@ -9,11 +9,11 @@
   <module name="TreeWalker">
     <module name="FileContentsHolder"/>
     <module name="SuppressWarningsHolder"/>
-    <module name="LocalFinalVariableName">
-      <property name="severity" value="info"/>
-    </module>
     <module name="LineLength">
       <property name="severity" value="error"/>
     </module>
+    <module name="LocalFinalVariableName">
+      <property name="severity" value="info"/>
+    </module>
   </module>
 </module>


4. Compile and package new sonar-checkstyle plugin v2.4-SNAPSHOT

$ mvn clean package


5. Use updated plugin in Sonar

$ rm [SONAR_HOME]/extensions/plugins/sonar-checkstyle-plugin-2.3.jar
$ cp target/sonar-checkstyle-plugin-2.4-SNAPSHOT.jar [SONAR_HOME]/extensions/plugins/
# restart sonar


Thanks,
Ruslan Diachenko

rd....@gmail.com

unread,
Jun 25, 2015, 1:33:16 PM6/25/15
to sona...@googlegroups.com, rd....@gmail.com
As a Checkstyle developer I can admit that there were no any special reasons for updating guava dependency to the latest version in Checkstyle project. Checksyle can still work fine on guava v15.0.

Roman Ivanov

unread,
Oct 8, 2015, 1:15:50 PM10/8/15
to SonarQube
Hi Nicolas,

You can override guava version that checkstyle use and use your version.

Checkstyle library got stable release cycle , we release it each month. We are already 6.11.2 and difference with 6.4 is huge. Custom extensions are also affected.

Thanks,
Roman Ivanov

Nicolas Peru

unread,
Oct 9, 2015, 3:25:50 AM10/9/15
to Roman Ivanov, SonarQube
Hi Roman, 

We are aware of it : https://jira.sonarsource.com/browse/SONARCHKST-36 we do follow checkstyle releases closely. We do not have a sprint on checkstyle plugin planned in the upcoming weeks but when it happens we will (for sure) handle that ticket to upgrade it.

Nicolas PERU | SonarSource
Senior Developer
http://sonarsource.com


--
You received this message because you are subscribed to the Google Groups "SonarQube" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sonarqube+...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages