Complexity

Complexity

 
Report:  Complexity, Functional Cyclomatic and Interface
Option:  -c
Compatible Options: RSM Option Cross Reference
Usage:
rsm -H -O"report.htm" -c *.cpp 
rsm -H -O"report.htm" -c *.java
Source:  C, C++, C# and Java
RSM determines the interface complexity and cyclomatic complexity for each Class and Function.  These complexity metrics can assist the user in the determination for module ease of use, whether or not the module should be multiple modules or the number of test cases a function should have for unit testing.

Interface Complexity: (InterCmp) is defined by RSM as the number of input parameters to a function plus the number of return states from that function.  Class interface complexity is the sum of all function interface complexity metrics within that class.

Cyclomatic Complexity: (CycloCmp) is the McCabe Cyclomatic complexity for a function.  The McCabe cyclomatic complexity has become the defacto industry standard for measuring the structural complexity of a function.  Cyclomatic complexity as defined by McCabe is the number of logical pathways through a function.   This metric can either be determined by counting the regions, nodes and edges or number of predicate nodes (branching points) with a flow graph.

The following equations defined McCabe Cyclomatic Complexity:
"Software Engineering, A Practioners Approach", Roger S. Pressman, McGraw Hill.

  1. The number of regions in a flow graph.
  2. V(G) = E - N + 2, where E are the edges and N are the nodes.
  3. V(G) = P + 1, where P are the predicate nodes.

The following hyperlink details the predicate node approach and relates the calculation to actual source code.  RSM is compliant with these definitions.  Cyclomatic Complexity Analysis