Sonar Violations


We are using Sonar 6.7.5. We are trying to determine the total number of bugs in Sonar to calculate the approximation of total number of bugs per 1000 lines of code (an industry standard to evaluate the quality fo code). I have calculated the total number of bugs by adding Violations, Major Violations, Critical Violations and Blocker violations. My question is, are these violations mutually exclusive? I thought they are based on what I see but I was not sure.

I see there are other kind of violations like New blocker violations, new critical violations etc but they are never populated in our case.

Thank you for your help


HI Vijay,

Each issue can have only 1 severity, so yes those are mutually exclusive.

However, I think this could be easier that you’re making it. Just look at the top-right corner of the issues page:

You’ll always see there the total count of issues that match your current search criteria. If you’re trying to get this number via web services, then run an issues search. The result will include a chunk of pagination information including total result count. Since you’re only after the count, use the query parameter &ps=1 (page size = 1, which is the minimum) to save the cycles of retrieving and returning a bunch of issues.


Thank you Ann for the response. Done further analysis based on your response and found Violations is a summation of set of different violations as shown below. Do you think this is a correct assumption?

Violations = Major_Violations + Minor_Violations + Blocker_Violations + Critical_Violations + Info_Violations


Hi Vijay,

Yes, that’s one way to slice it. Another would be Bugs + Vulnerabilities + Code Smells. Another is to look at the total number of Issues.