GMetrics

The GMetrics project provides calculation and reporting of size and complexity metrics for Groovy source code. GMetrics scans Groovy source code, applying a set of metrics, and generates an HTML report of the results.

This project is maintained by dx42

ABC Metric

Calculates the ABC Metric for a class or method. ABC is a metric of size/complexity that counts the number of Assignments (A), Branches (B) and Conditions (C) and assigns a single numerical score calculated as:

|ABC| = sqrt((A*A)+(B*B)+(C*C))

Implemented by the org.gmetrics.metric.abc.AbcMetric class.

The ABC Metric calculation rules for Groovy:

Additional notes

Guidelines for Interpreting ABC Metric Values

A frequently-referenced blog post by Jake Scruggs ([4]) offers the following guidelines for interpreting an ABC score. Note that these values refer to the score (magnitude) calculated for a single method:

Metric Properties

The following properties can be configured for this metric within a MetricSet. See Creating a MetricSet for information on the syntax of setting a metric property.

Property Description Default Value
enabled This boolean property controls whether the metric is enabled. If set to false, then the metric is not included as part of the results or the output reports. true
functions This List<String> property contains the names of the functions to be calculated at the method, class and package levels and (potentially) included within the report(s). Valid values are: “total”, “average”, “minimum”, “maximum” ["total","average"]
includeClosureFields This boolean property controls whether metric values are calculated for Closure Fields and treated as methods. A Closure Field is a field that is initialized to a Closure Expression, e.g., def myField = { println 12 }. true

References