Ratio of number of comments to number of statements
The metric specifies the ratio of comments to statements expressed as a percentage.
Based on HIS specifications:
Multi-line comments count as one comment.
For instance, the following constitutes one comment:
// This function implements // regular maintenance on an internal database
Comments that start with the source code line do not count as comments.
For instance, this comment does not count as a comment for the metric but counts as a statement instead:
remove(i); // Remove employee record
A statement typically ends with a semi-colon with some exceptions.
Exceptions include semi-colons in for loops or structure
field declarations.
For instance, the initialization, condition and increment within
parentheses in a for loop is counted as one statement.
The following counts as one
statement:
for(i=0; i <100; i++)
The recommended lower limit for this metric is 20. For better readability of your code, try to place at least one comment for every five statements.
To enforce limits on metrics:
In the Polyspace® user interface, see Compute Code Complexity Metrics.
In the Polyspace Metrics web interface, see Compare Metrics Against Software Quality Objectives.
| Group: File |
Acronym: COMF |
| HIS Metric: Yes |