Full documentation for SonarQube has moved to a new location: http://docs.sonarqube.org/display/SONAR

Skip to end of metadata
Go to start of metadata

Table of Contents

Get the Details of a Rule

DescriptionGet the details of a rule

URL

/api/rules/show

HTTP MethodGET
Response Formatsjson

Security

None

Examples

Use CaseExample Request
Get the details of rule "squid:S1219"

GET http://nemo.sonarsource.org/api/rules/show?key=squid:S1219

Response Format

JSON

Parameters

Parameter

Description

Required

Default Value

Example Value

key

Rule key

Yes

None
squid:S1219

Get a List of Rules

DescriptionGet a list of rules

URL

/api/rules

HTTP MethodGET
Response Formatsjson | xml | csv

Security

None

Examples

Use CaseExample Request
Get all the java rules

GET http://nemo.sonarsource.org/api/rules?language=java

Get all the java rules from pmd and findbugs

GET http://nemo.sonarsource.org/api/rules?language=java&plugin=pmd,findbugs

Response Format

JSON

Parameters

Parameter

Description

Required

Default Value

Example Value

language

Key of the language

No

Nonejava

plugin

Comma-separated list of rules plugins

No

None

findbugs,pmd

searchtext

To filter on rules containing a specified text in their name, key or title

No

None

braces

profile

Used to list the rules of a given quality profile. Must be used with the "status parameter.
It is recommended to use the /api/profiles web service instead. 

No

None

Sonar%20way

priorities

List of BLOCKER, CRITICAL, MAJOR, MINOR, INFO.

No

None

BLOCKER,CRITICAL

status

Used with "profile": he activation status of the rule on a given profile. Can be 'INACTIVE' or 'ACTIVE'.
It is recommended to use the /api/profiles web service instead. 

NoNoneACTIVE
format

Response format can be set through:

  • Parameter format: xml | json | csv
  • Or the 'Accept' property in the HTTP header:
    • Accept:text/xml
    • Accept:application/json
If nothing is set, json is used.
NoNonejson

Add Tags to a Rule

DescriptionAdd tags to a rule

URL

/api/rule_tags/add

HTTP MethodPOST

Security

Requires Administer Quality Profiles permission

Available sinceVersion 4.2

Examples

Use CaseExample Request
Add tags "mytag" and "yourtag" to rule "squid:S1219" 

curl -X POST -v -u admin:admin "http://localhost:9000/api/rules/add_tags?key=squid:S1219&tags=mytag,yourtag"

Parameters

Parameter

Description

Required

Default Value

Example Value

key

Rule keyYes

None

squid:S1219

tagsComma-separated list of tagsYesNonemytag,yourtag

Remove Tags From a Rule

DescriptionRemove tags from a rule

URL

/api/rule_tags/remove

HTTP MethodPOST

Security

Requires Administer Quality Profiles permission

Available sinceVersion 4.2

Examples

Use CaseExample Request
Remove tags "mytag" and "yourtag" from rule "squid:S1219" 

curl -X POST -v -u admin:admin "http://localhost:9000/api/rules/remove_tags?key=squid:S1219&tags=mytag,yourtag"

Parameters

Parameter

Description

Required

Default Value

Example Value

key

Rule keyYes

None

squid:S1219

tagsComma-separated list of tagsYesNonemytag,yourtag
  • No labels