Violations Density

Concept

The Violations Density intends to highlight the part of the code with the most violated rules (of "Non Conformity" or "Risky Construction" nature). The density takes into account the severity of the issues which are detected: the density is weighted by the findings severity. This allows to highlights either:

  • Code with blocker/critical issues

  • Code with a lot of minor/major issues

In both cases, remediation shall be performed to improve code quality.

Formula

Violation Density = (sum(issue * severity)) / code size)

Where:

  • Code size is expressed in KEloc (Effective Lines /1000)

  • Severity weights are:

Severity

Weight

Minor

0.1

Major

5

Critical

20

Blocker

100

The rating is based on the following scale:

SWAN violation density scale
Figure 1. Violations Density - Scale

A component which is rated "G" has in average the equivalent of 10 blocker issues every 1000 lines.

The Violation Density Treemap

The treemap highlights the component according to:

  • Their code size (=size of the treemap zone)

  • Their violation density (=color of the treemap zone)

SWAN violation density treemap
Figure 2. Violations Density - Treemap