# Metrics Checks

## BooleanExpressionComplexity

#### Description

Restrict the number of number of &&, || and ^ in an expression.

Rationale: Too many conditions leads to code that is difficult to read and hence debug and maintain.

#### Properties

name | description | type | default value
--- | --- | --- | ---
max | the maximum allowed number of boolean operations in one experession. | integer | 3

#### Examples

To configure the check:

    <module name="BooleanExpressionComplexity"/>

To configure the check with 7 allowed operation in boolean expression:

    <module name="BooleanExpressionComplexity">
        <property name="max" value="7"/>
    </module>

#### Package

com.puppycrawl.tools.checkstyle.checks.metrics

#### Parent Module

TreeWalker

## ClassDataAbstractionCoupling

#### Description

This metric measures the number of instantiations of other classes within the given class. This type of coupling is not caused by inheritance or the object oriented paradigm. Generally speaking, any abstract data type with other abstract data types as members has data abstraction coupling; therefore, if a class has a local variable that is an instantiation (object) of another class, there is data abstraction coupling. The higher the DAC, the more complex the data structure (classes) of the system.

#### Properties

name | description | type | default value
--- | --- | --- | ---
max | the maximum threshold allowed | integer | 7

#### Examples

To configure the check:

    <module name="ClassDataAbstractionCoupling"/>

To configure the check with a threshold of 5:

    <module name="ClassDataAbstractionCoupling">
        <property name="max" value="5"/>
    </module>

#### Package

com.puppycrawl.tools.checkstyle.checks.metrics

#### Parent Module

TreeWalker

## ClassFanOutComplexity

#### Description

The number of other classes a given class relies on. Also the square of this has been shown to indicate the amount of maintenence required in functional programs (on a file basis) at least.

#### Properties

name | description | type | default value
--- | --- | --- | ---
max | the maximum threshold allowed | integer | 20

#### Examples

To configure the check:

    <module name="ClassFanOutComplexity"/>

To configure the check with a threshold of 10:

    <module name="ClassFanOutComplexity">
        <property name="max" value="10"/>
    </module>

#### Package

com.puppycrawl.tools.checkstyle.checks.metrics

#### Parent Module

TreeWalker

## CyclomaticComplexity

#### Description

Checks cyclomatic complexity against a specified limit. The complexity is measured by the number of if, while, do, for, ?:, catch, switch, case statements, and operators && and || (plus one) in the body of a constructor, method, static initializer, or instance initializer. It is a measure of the minimum number of possible paths through the source and therefore the number of required tests. Generally 1-4 is considered good, 5-7 ok, 8-10 consider re-factoring, and 11+ re-factor now!

#### Properties

name | description | type | default value
--- | --- | --- | ---
max | the maximum threshold allowed | integer | 10

#### Examples

To configure the check:

    <module name="CyclomaticComplexity"/>

To configure the check with a threshold of 7:

    <module name="CyclomaticComplexity">
        <property name="max" value="7"/>
    </module>

#### Package

com.puppycrawl.tools.checkstyle.checks.metrics

#### Parent Module

TreeWalker

## NPathComplexity

#### Description

The NPATH metric computes the number of possible execution paths through a function. It takes into account the nesting of conditional statements and multi-part boolean expressions (e.g., A && B, C || D, etc.).

Rationale: Nejmeh says that his group had an informal NPATH limit of 200 on individual routines; functions that exceeded this value were candidates for further decomposition - or at least a closer look.

#### Properties

name | description | type | default value
--- | --- | --- | ---
max | the maximum threshold allowed | integer | 200

#### Examples

To configure the check:

    <module name="NPathComplexity"/>

To configure the check with a threshold of 20:

    <module name="NPathComplexity">
        <property name="max" value="20"/>
    </module>

#### Package

com.puppycrawl.tools.checkstyle.checks.metrics

#### Parent Module

TreeWalker

Back to the Checkstyle Home Page

Copyright © 2002-2003 Oliver Burn. All rights Reserved.