Code Comments
Purpose
Code Comments metric shows a percentage of comment lines in total amount of lines in source code.
How metric helps
Code comments are an essential element of code documentation. Comments increase readability and facilitate on-boarding of a new developers into a team. In addition, well-commented code usually takes less efforts for its maintenance. So, a reasonable amount of comments in code helps to bring clarity on how that code works.
How it works
Chart Overview
Chart shows code comments density percentage (Axis Y) distributed on the day-by-day timeline (Axis X). Summed % for each sub-unit (can be configured in Project Configuration wizard) is displayed in the legend of the chart. Sub-units are clickable so that their series are shown/hidden on the chart.
On hover over a point, a hint appears with the following information:
Metric value in percentage;
Date a value is calculated for.
Chart legend shows the latest values for the metric by project.
Calculation Formula
Code Comments, % = Comment lines / (Total LOC + Comment lines) * 100%.,
where
Comment lines - number of lines with comments
Total LOC - total number of "lines of code"
RAG thresholds: Red - metric value < 3% or > 20%; Amber - metric value < 5% or > 15%; Green - metric value within 5%..15%.
Data Source
Data for the metric can be collected from Sonar.