Skip to content

Metric Definitions

Cyclomatic Complexity

Measures the structural complexity of the code.

It is created by calculating the number of different code paths in the flow of the program. A program that has complex control flow requires more tests to achieve good code coverage and is less maintainable.

For more information, see https://en.wikipedia.org/wiki/Cyclomatic_complexity.

Maintainability Index

An index value between 0 and 100 that represents the relative ease of maintaining the code. A high value means better maintainability.

Maintainability Index = MAX(0, (171 - 5.2 * ln(Halstead Volume) - 0.23 * (Cyclomatic Complexity) - 16.2 * ln(Lines of Code))*100 / 171)

For more information, see https://docs.microsoft.com/en-us/archive/blogs/codeanalysis/maintainability-index-range-and-meaning and http://www.virtualmachinery.com/sidebar2.htm for definitions of Halstead metrics.

Coupled Types

Measures how many types a type uses.

Giving a more exact definition, it means coupling to types through parameters, local variables, return types, method calls, generic or template instantiations, base classes, interface implementations, fields defined on external types, and attribute decoration.

In well-designed software, types and methods should have high cohesion and low coupling. High coupling indicates a design that is difficult to reuse and maintain because of its many interdependencies on other types.

Example:

class MyType
{
    int x; // Doesn't count.
    string name; // Doesn't count.
    Reward reward; // Counts as 1 coupled type.
}

Source Lines

Indicates the exact number of source code lines that are present in your source file, including blank lines.