Metrics Checks |
![]() |
BooleanExpressionComplexityDescriptionRestrict 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
ExamplesTo 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> Packagecom.puppycrawl.tools.checkstyle.checks.metrics Parent ModuleClassDataAbstractionCouplingDescriptionThis 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
ExamplesTo configure the check: <module name="ClassDataAbstractionCoupling"/> To configure the check with a threshold of 5: <module name="ClassDataAbstractionCoupling"> <property name="max" value="5"/> </module> Packagecom.puppycrawl.tools.checkstyle.checks.metrics Parent ModuleClassFanOutComplexityDescriptionThe 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
ExamplesTo configure the check: <module name="ClassFanOutComplexity"/> To configure the check with a threshold of 10: <module name="ClassFanOutComplexity"> <property name="max" value="10"/> </module> Packagecom.puppycrawl.tools.checkstyle.checks.metrics Parent ModuleCyclomaticComplexityDescriptionChecks 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
ExamplesTo configure the check: <module name="CyclomaticComplexity"/> To configure the check with a threshold of 7: <module name="CyclomaticComplexity"> <property name="max" value="7"/> </module> Packagecom.puppycrawl.tools.checkstyle.checks.metrics Parent ModuleNPathComplexityDescriptionThe 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
ExamplesTo configure the check: <module name="NPathComplexity"/> To configure the check with a threshold of 20: <module name="NPathComplexity"> <property name="max" value="20"/> </module> Packagecom.puppycrawl.tools.checkstyle.checks.metrics Parent Module |
Copyright © 2002-2003 Oliver Burn. All rights Reserved.