Active severity for a quality profile in web api 'api/rules/search' response

105 views
Skip to first unread message

Christian Schmitt

unread,
Oct 16, 2017, 8:14:36 AM10/16/17
to SonarQube
Hi,

i want to get the active severity for rules in my quality profile.
With the WEB API documentation i tried several calls but never got the active severity in my response.

My current call is:

https://XXX/api/rules/search?activation=true&qprofile=XXX&ps=290&f=severity,name,htmlDesc,htmlNote,params,actives&active_severities=INFO,MINOR,MAJOR,CRITICAL,BLOCKER&facets=active_severities



The response said that 'activities' are not part of the 'f' parameter.

Is it possible to get this information with the WEB API? If yes, how?`

I am using SQ version  6.4 (build 25310)

Thx
Christian

G. Ann Campbell

unread,
Oct 16, 2017, 10:24:17 AM10/16/17
to SonarQube
Hi Christian,

Just looking at the API docs, I would have expected 'severity' to hold the value you want. What it present and blank, or not present?


Ann

Christian Schmitt

unread,
Oct 16, 2017, 11:21:54 AM10/16/17
to SonarQube
Hi Ann.

that was my expectation as well but severity in the response hold the default severity of the rule and not the active severity from the Quality Profile.

Example response:
"key": "squid:S00117",
            "name": "Local variable and method parameter names should comply with a naming convention",
            "htmlDesc": "<p>Sharing some naming conventions is a key point to make it possible for a team to efficiently collaborate. This rule allows to check that all local\nvariable and function parameter names match a provided regular expression.</p>\n<h2>Noncompliant Code Example</h2>\n<p>With the default regular expression <code>^[a-z][a-zA-Z0-9]*$</code>:</p>\n<pre>\npublic void doSomething(int my_param) {\n  int LOCAL;\n  ...\n}\n</pre>\n<h2>Compliant Solution</h2>\n<pre>\npublic void doSomething(int myParam) {\n  int local;\n  ...\n}\n</pre>\n<h2>Exceptions</h2>\n<p>Loop counters are ignored by this rule.</p>\n<pre>\nfor (int i_1 = 0; i_1 &lt; limit; i_1++) {  // Compliant\n  // ...\n}\n</pre>",
            "htmlNote": "<h2>Lorem ipsum...<br/></blockquote>",
            "severity": "MINOR",
            "params": [
                {
                    "key": "format",
                    "htmlDesc": "Regular expression used to check the names against.",
                    "defaultValue": "^[a-z][a-zA-Z0-9]*$",
                    "type": "STRING"
                }
            ],
            "type": "CODE_SMELL"

As shown in the example it returns "MINOR" as severity but for our quality profile we set the severity to "MAJOR".
And i added my quality profile as request parameter but no "MAJOR" found in the response.

Christian

G. Ann Campbell

unread,
Oct 16, 2017, 11:28:06 AM10/16/17
to Christian Schmitt, SonarQube



---
G. Ann Campbell | SonarSource
Product Manager
@GAnnCampbell

--
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/FLXs9600nCc/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/49e806c7-a3cf-4ae6-9968-3d585835e741%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Christian Schmitt

unread,
Oct 16, 2017, 3:01:53 PM10/16/17
to SonarQube
Hi Ann,

this returns both. The default severity (MINOR) and the severity in the active quality profiles (MAJOR).

Is there no other way to get it in rules/search webservice? I need an overview of all quality gate rules with defined fields.

Christian
To unsubscribe from this group and all its topics, send an email to sonarqube+...@googlegroups.com.

G. Ann Campbell

unread,
Oct 16, 2017, 3:15:40 PM10/16/17
to Christian Schmitt, SonarQube
Hmm,

Well, it looks like the search service has an 'actives' parameter too. And an 'actives' field:



Ann



---
G. Ann Campbell | SonarSource
Product Manager
@GAnnCampbell

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/bc142403-2ec8-4564-9b49-249a779de37d%40googlegroups.com.

Christian Schmitt

unread,
Oct 18, 2017, 3:21:51 AM10/18/17
to SonarQube
Hi Ann,

i used your proposal as base.
My current query is https://<server>/api/rules/search?f=actives,name,htmlDesc,htmlNote,severity,params&actives=true&qprofile=XXX&activation=true

This returns the qprofile severity under "actives" and the default severity under "rules".
I think this helped me.

Thx,
Christian
Reply all
Reply to author
Forward
0 new messages