Does SonarQube report Defect(issue) Density?

Hello Everyone,

I’ve been looking around my 7.9 version for a metric that describes the number of issues per lines of code to provide a Defect Density measurement.

Does SonarQube have such a metric?

Thanks for the help!


Hi Steve,

We don’t calculate that kind of metric because we don’t find it to be terribly useful. Why? It’s easy enough to manipulate such numbers based on what rules you include or exclude from your profile. Further, it wouldn’t be nuanced enough to take into account Blocker versus Info issues, or Bugs versus Code Smells.


You can easily compute this yourself via the Web API. Retrieve the NCLOC measure and whatever type of issues you want, total issues, blockers, etc, then divide the issue measure by NCLOC. You can retrieve all the measures in one web call so this should be fairly quick.