Metric-HIS.COMF

HIS COMF metric: 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

alias_name

alias_name : str = 'Metric.HIS.COMF'

Name under which the metric will be reported. In the RFG, a metric with this value is created, too (copied from original metric).
 

display_name

display_name : str | None = 'HIS COMF'

Description of the metric shown in the dashboard. If None, rfg_metric_name is used.
 

max_value

max_value : float | None = None

Maximum allowed value. None if unlimited.
 

min_loc

min_loc : int | None = None

Minimal LOC threshold that a function must at least cross in order to be considered. If None, all functions are considered.
 

min_value

min_value : float | None = 0.2

Minimum allowed value. None if unlimited.
 

rfg_metric_name

rfg_metric_name : OriginalMetrics = 'Metric.Comment.Density'

Name of the node attribute storing the metric value in the RFG. The name of the RFG node attribute of the original metric.
 

Option Types

These types are used by options listed above:

OriginalMetrics

An enumeration.
 
  • Metric.Comment.Density