Metric-Comment.Density¶
Comment Density
Required inputs: RFG
Computes the comment density (also called comment frequency) of a routine, which roughly corresponds to the ratio between comments before, within, and on the same line as the routine and the number of statements of the routine. For a given routine r, let st(r) be the number of statements of the routine. Let p(r) be the number of comments before the routine and on the same line as the routine definition, i.e., the value Metric.Comment.Preceding, and let i(r) be the number of comments within the routine, i.e., the value Metric.Comment.Internal. Then the comment density d(r) of r is computed as follows:
comments(r) = p(r) + i(r)
if (st(r) > 0) {
d(r) = comments(r) / st(r)
} else if (comments(r) > 0) {
d(r) = MAX_INT
} else {
d(r) = 0
}
Possible Messages
This rule has no predefined messages.
Options¶
This rule shares the following common options: exclude_messages_in_system_headers, excludes, includes, justification_checker, post_processing, provider, severity
This rule shares the following common metric options: base_view_name, excluded_node_types, hierarchy_edge_name, hierarchy_view_name, propagate, report_all_values, report_propagated_values
The following places define options that affect this rule: CommentMetrics, Analysis-GlobalOptions
display_name¶
display_name : str | None = 'Comment Density'
max_value¶
max_value : float | None = None
min_value¶
min_value : float | None = 0.2
rfg_metric_name¶
rfg_metric_name : str = 'Metric.Comment.Density'