Function Comment Density
Ratio of number of comments to number of statements in function
Description
This metric specifies the ratio of comments to statements in a function expressed as a percentage:
Function Comment Density = 100 * (Number of comments associated with a function / Number of statements in function body)
Polyspace® considers these comment blocks to be associated with a function:
Comment blocks immediately preceding a function
Comment blocks between the first token of the function declaration and the final brace of the function.
When counting comments for this metric, Polyspace:
Counts multiline comments as a single comment, regardless of spacing or indentation.
Counts the header comments for functions. Consider this code:
Polyspace counts the comment//Comment void foo() {}
//Comment
when calculating the function comment density. For the file-level metricComment Density
, comments that occur before the first statement are ignored.Counts comments that start with a code line. Consider this code:
Polyspace counts the commentint var = 5; // variable
//variable
when calculating function comment density. For the file-level metricComment Density
, such comments are ignored.
The number of statements in the function body is based on the number of semicolons in
the function after the code is preprocessed and the macros are expanded. For details about
how statements are counted for this metric, see Comment Density
.
Polyspace does not calculate this metric for these functions:
Functions that are declared but not defined
Function templates
Member functions of a class template
Defaulted or deleted class member functions
Examples
Metric Information
Group: Function |
Acronym: FCOMF
|
HIS Metric : No |