Skip to end of metadata
Go to start of metadata
You are viewing an old version of this page. View the current version. Compare with Current ·  View Page History
DescriptionGet a list of violations

URL

/api/violations

HTTP MethodGET
Response Formatsjson | xml

Security

Requires User role on project

Examples

Use CaseExample Request
Get all the violations from project Sonar (key = org.codehaus.sonar:sonar):

GET http://nemo.sonarsource.org/api/violations?resource=org.codehaus.sonar:sonar&depth=-1

Get all the blocker and critical violations from project Sonar (key = org.codehaus.sonar:sonar):

GET http://nemo.sonarsource.org/api/violations?resource=org.codehaus.sonar:sonar&depth=-1&priorities=BLOCKER,CRITICAL

Parameters

Parameter

Description

Required

Default Value

Example Value

resource

id or key of the resource.

Yes

None

org.codehaus.sonar:sonar

depth

Used only when resource is set. 

  • 0: only selected resource 
  • -1: all children, including selected resource 
  • >0: depth toward the selected resource
No

0

-1

scopes

Comma-separated list of scopes:

  • PRJ: project/module 
  • DIR: directory (like Java package) 
  • FIL: file
No

None

PRJ,FIL

qualifiers

Comma-separated list of qualifiers: 

  • TRK: project 
  • BRC: module 
  • CLA: class 
  • UTS: unit test 
  • DIR: directory 
  • FIL: file
No

None

TRK,BRC

rules

Comma-separated list of rule keys or ids.

No

None

squid:MethodCyclomatiComplexity,pmd:ConstructorCallsOverridableMethod

priorities

Comma-separated list of priorities.
Possible values: BLOCKER | CRITICAL | MAJOR | MINOR | INFO

No

None

BLOCKER,CRITICAL

limit

Maximum number of results

No

5000

10

include_review

Include review data into response.
Possible values: true | false

No

false

true

output

Output format of review comments. Ignored if include_review is false.
Possible values: PLAIN | HTML 

No

PLAIN

HTML

switched_off

If true, then return only switched-off violations (usually false-positives), 
else switched-off violations are excluded.
Possible values: true | false 

No

false

true
formatResponse formats.
Possible values: xml | json
NoNonejson
Labels
  • None