Cyclomatic complexity can
be applied in several areas, including
Code development risk analysis. While code is under
development, it can be measured for complexity to assess inherent risk or
risk buildup.
Change risk analysis in maintenance. Code complexity tends to
increase as it is maintained over time. By measuring the complexity before
and after a proposed change, this buildup can be monitored and used to help
decide how to minimize the risk of the change.
Test Planning. Mathematical analysis has shown that cyclomatic
complexity gives the exact number of tests needed to test every decision
point in a program for each outcome. Thus, the analysis can be used for test
planning. An excessively complex module will require a prohibitive number of
test steps; that number can be reduced to a practical size by breaking the
module into smaller, less-complex sub-modules.
Reengineering. Cyclomatic complexity analysis provides
knowledge of the structure of the operational code of a system. The risk
involved in reengineering a piece of code is related to its complexity.
Therefore, cost and risk analysis can benefit from proper application of
such an analysis.
Cyclomatic complexity can
be calculated manually for small program suites, but automated tools are
preferable for most operational environments. For automated graphing and
complexity calculation, the technology is language-sensitive; there must be a
front-end source parser for each language, with variants for dialectic
differences.