rascalcyclomatic-complexity

Obtaining Cyclomatic Complexity


I am looking into calculating the cyclomatic complexity of java methods using Rascal.

One approach to this would be:

Another one is using graph theory and using the formula e-n+2. both e and n can be obtained quite easily using rascal functionality. My problem is how do I go about constructing the control flow graph, I found the following module: analysis::flow::ControlFlow which seems to be a step in the right direction but I am totally lost on where to go from there.


Solution

  • For construction control flow graphs in Rascal, there is a paper which explains how to do it in pure Rascal and how to raise the abstraction level using a declarative language called DCFlow: http://link.springer.com/chapter/10.1007%2F978-3-319-11245-9_18