This plugin is deprecated since SonarQube 3.7. Please move to the concept of Technical Debt introduced in SonarQube 4.0. |

This plugin is an implementation of the **Toxicity Chart** visualization technique presented by Erik Dörnenburg on his blog. This technique is useful to quickly get an idea of the general quality of a large existing code base. **Toxicity Charts** stack multiple static analysis metrics for classes, methods, or components within an application, providing a combined "toxicity" score for each area of the code base. This can be extremely useful in helping managers and non-developers understand the internal quality of the code

In a **Toxicity Chart** each bar represents a class and the height of the bar shows the toxicity score for that class. The score is based on 11 rules (see Usage & Installation section) and different colours are used to represent each one. This makes it possible to easily spot not only how toxic a code base is, but also how the problems are distributed and what the preponderant "code smell" is. The classes that score zero points are left off the chart. The metrics are computed using the threshold value set for corresponding Checkstyle rule.

For example if the Method Length metric has a threshold of **30** and a class comprises three methods, one that is **25** lines, one that is **45** lines and another that is **60** lines long, then the score is calculated to be proportional to the length of the method in relation to the threshold and for the given scenario the class gets **1.5 + 2 = 3.5** points.

All the metrics are computed using the approach presented above.

Total of points accumulated due to the violation of Checkstyle File Length rule. The possible associated technical debts are: Understandability, Maintainability and Single Responsibility Principle violation.

Total of points accumulated due to the violation of Checkstyle Method Length rule. The possible associated technical debts are: Understandability, Maintainability and Single Responsibility Principle violation.

Total of points accumulated due to the violation of Checkstyle Cyclomatic Complexity rule. The possible associated technical debts are: Understandability, Maintainability and Testability.

Total of points accumulated due to the violation of Checkstyle Parameter Number rule. The possible associated technical debts are: Understandability, Maintainability and Testability.

Total of points accumulated due to the violation of Checkstyle Boolean Expression Complexity rule. The possible associated technical debts are: Understandability, Maintainability and Testability.

Total of points accumulated due to the violation of Checkstyle Nested If Depth rule. The possible associated technical debts are: Understandability, Maintainability and Testability.

Total of points accumulated due to the violation of Checkstyle Nested Try Depth rule. The possible associated technical debts are: Understandability, Maintainability and Testability.

Total of points accumulated due to the violation of Checkstyle Missing Switch Default rule. The possible associated technical debt is: Correctness.

Total of points accumulated due to the violation of Checkstyle Class Fan out Complexity rule. The possible associated technical debts are: Understandability, Maintainability, Testability and High Coupling.

Total of points accumulated due to the violation of Checkstyle Class Data Abstraction Coupling rule. The possible associated technical debts are: Understandability, Maintainability, Testability and High Coupling.

Total of points accumulated due to the violation of Checkstyle Anon Inner Length rule. The possible associated technical debt is: Maintainability.

Total of points accumulated due violation of all above rules divided by the number of classes that score more than one point.

- Make sure the Checkstyle Rules listed below are enabled in your profile and that the threshold values are set appropriately.
- Launch a new quality analysis to calculate the metrics.

The table below lists the Squid rules that should be **enabled** in order to generate the **Toxicity Chart**. The threshold values are just suggestions and they can be modified to fit the desired Quality Profile. The deprecated Checkstyle Rules still apply, however, the Squid Rules are highly recommended.

Checkstyle Rule (deprecated ) | Squid Rule (highly recommended) | Level | Threshold |
---|---|---|---|

File Length | S00104 | file | 500 |

Method Length | S138 | method | 30 |

Cyclomatic Complexity | MethodCyclomaticComplexity | method | 10 |

Parameter Number | S00107 | method | 7 |

Boolean Expression Complexity | S1067 | statement | 3 |

Nested If Depth | S134 | statement | 3 |

Nested Try Depth | S1141 | statement | 2 |

Missing Switch Default | SwitchLastCaseIsDefaultCheck | statement | - |

Class Fan Out Complexity | S1200 | class | 30 |

Class Data Abstraction Coupling | - | class | 10 |

Anon Inner Length | S1188 | inner class | 35 |

If the number of classes that score more than one point is greater than 125, then the numbers on the X axis will overlap each other. In order to make the chart readable in this situation the **Toxicity Chart** threshold value can be changed in *Configuration > General Settings > Toxicity Chart panel*. The classes that have the score below the threshold value are left off the chart. The threshold value is not taken into account in toxicity metrics computing.

Only Java projects are supported.