How to tell to my own rule that's a bug or a vulnerabilitie rule ?

54 views
Skip to first unread message

samuel....@gmail.com

unread,
Jun 2, 2017, 3:57:24 AM6/2/17
to SonarQube
Hi !
As i see here, our rules have differents types (vulnerabilities, bugs, code smells) : https://docs.sonarqube.org/display/SONAR/Rules
But i can't below add the type option :
@Rule(
    priority = Priority.CRITICAL, 
    name = "Mea Culpa", 
    tags = {"Mea", "Culpa"},
    description ="Mea Culpa"
)
So how can i add the type of my rule ?

Julien Lancelot

unread,
Jun 5, 2017, 2:36:58 AM6/5/17
to samuel....@gmail.com, SonarQube

--
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/b9ff5c8e-901e-4d32-90d6-1d5a40c94bb7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
Julien Lancelot | SonarSource

samuel....@gmail.com

unread,
Jun 6, 2017, 3:33:43 AM6/6/17
to SonarQube, samuel....@gmail.com
With this API, where should i call my rules already define ? Because i've a template, and i just want to add the type so if my rules is already defined, where should i call the API to add type ?

samuel....@gmail.com

unread,
Jun 7, 2017, 3:59:53 AM6/7/17
to SonarQube, samuel....@gmail.com
After some research, i found the solution, thanks for your help ! :)

Julien Lancelot

unread,
Jun 7, 2017, 6:58:24 AM6/7/17
to samuel....@gmail.com, SonarQube
Thanks for your answer.

Could you please share the solution you've found, to help people that could be in the same situation ?
Thanks.

Regards,

On Wed, 7 Jun 2017 at 09:59 <samuel....@gmail.com> wrote:
After some research, i found the solution, thanks for your help ! :)

--
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.

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

samuel....@gmail.com

unread,
Jun 8, 2017, 6:12:33 AM6/8/17
to SonarQube, samuel....@gmail.com
My rules aren't defined in the same class as the definition but they are imported with the annotationBasedRulesDefinition.
So i called my rule after i have added my class rules like that in the define:

repository.rule("RuleKey").setType(TypeWanted);

and after you call repository.done().

But don't forget to declare TypeWanted like that :

private static final RuleType TypeWanted = RuleType.TypeWanted;

Julien HENRY

unread,
Jun 9, 2017, 2:54:26 AM6/9/17
to SonarQube, samuel....@gmail.com
Hi guys,

Another option is to use the "special" tags "bug" or "security":

@Rule(
    priority = Priority.CRITICAL, 
    name = "Mea Culpa", 

samuel dubernet

unread,
Jun 9, 2017, 2:55:29 AM6/9/17
to Julien HENRY, SonarQube
Thanks!
Reply all
Reply to author
Forward
0 new messages