How to set existing rules parameters of Checkstyle on Sonarqube from rules xml file?

806 views
Skip to first unread message

ozl...@gmail.com

unread,
Nov 30, 2016, 3:14:32 AM11/30/16
to SonarQube

I want to import my checkstyle rules to Sonarqube by setting their parameters according to me. I use Checkstyle Sonar plugin in language Java that my Sonar repository read from rules definition XML file by using RulesDefinitionXmlLoader.

Suppose that I have the following rules XML file to load Sonarqube that contains my custom Checkstyle rules and also LineLength check that is already exists in Checkstyle:

<rules> <rule> <key>LineLength</key> <name>Line Length</name> <description>Line Length</description> <internalKey>Checker/TreeWalker/LineLength</internalKey> <param key="max" name="Max"> <defaultValue>120</defaultValue> <description>Max property with value of '120'</description> </param> </rule> <rule> <key>CustomCheck</key> <name>CustomCheck</name> <description>any custom check</description> <internalKey>Checker/TreeWalker/CustomCheck</internalKey> <param key="anyParam" name="any"> <defaultValue>any</defaultValue> <description>any param value</description> </param> </rule> </rules>

I want to use these rules on Sonarqube. My custom rule and LineLength rule are created on Sonarqube with given parameters. I activated two of them on my used profile. My custom rule successfully works on git pull requests but LineLength check do not works on pull requests. Because there is already LineLength check on Sonarqube that comes from Checkstyle plugin so two LineLength rules seem on the dashboard of Sonarqube. But I want to override existing LineLength check by giving its parameters what I want from my Sonar rule XML file. Note that when I activated two of LineLength rule, two of them successfully works but I do not want to the already existing LineLength rule to work, I want to my LineLength check with my parameters.

G. Ann Campbell

unread,
Nov 30, 2016, 8:36:38 PM11/30/16
to SonarQube
Hi,

Have you tried renaming your "LineLength" rule?


:-)
Ann

Özlem Ulağ

unread,
Nov 30, 2016, 11:57:56 PM11/30/16
to G. Ann Campbell, SonarQube
Thanks Ann :)

But it's name is LineLength in Checkstyle. Full package name is com.puppycrawl.tools.checkstyle.checks.sizes.LineLengthCheck. I have lots of rules in Checkstyle to load Sonarqube but I only give as an example this rule.

--
You received this message because you are subscribed to a topic in the Google Groups "SonarQube" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/sonarqube/cE0IM0N2swU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to sonarqube+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sonarqube/209bc85e-b2a0-4650-a8ce-d568cb212e22%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--

Saygılarımla.

 

Özlem ULAĞ

Software Engineer

G. Ann Campbell

unread,
Dec 1, 2016, 2:44:29 PM12/1/16
to SonarQube, ann.ca...@sonarsource.com
I've just discovered that this is a cross-post, here and on StackOverflow. Please don't do that.

Özlem Ulağ

unread,
Dec 2, 2016, 1:54:08 AM12/2/16
to G. Ann Campbell, SonarQube
Sorry but I do not undestand why you said that "don't do that.".  Yes this is also my question on Stackoverflow. I have a problem and I want to solve this problem so I asked this problem on different platforms. There is a such rule that I do not know? If I learn the solution of this problem then I will update my question with the answer on each platforms so many people who face the same problem will learn the answer.

Thanks for your replies.


For more options, visit https://groups.google.com/d/optout.

G. Ann Campbell

unread,
Dec 2, 2016, 7:28:41 AM12/2/16
to Özlem Ulağ, SonarQube
Hi,

Yeah, it is a rule - at least within this group. Re-read the welcome message at the top of the page, and you'll see it mentioned explicitly.

Why? Because we at SonarSource do actively monitor both channels, but we have limited time for community support. So by cross-posting, you've taken twice your share of bandwidth.


Ann



---
G. Ann CAMPBELL | SonarSource
Product Owner

Özlem Ulağ

unread,
Dec 2, 2016, 7:43:33 AM12/2/16
to G. Ann Campbell, SonarQube
Ok. My apologies. Thanks.
Reply all
Reply to author
Forward
0 new messages