Skip to content

Commit

Permalink
Merge pull request #16 from sinha108/main
Browse files Browse the repository at this point in the history
Updated cyclomatic complexity computation to run on CG nodes
  • Loading branch information
sinha108 authored May 3, 2024
2 parents 23dbbdd + c500e50 commit 8e65f4a
Showing 1 changed file with 8 additions and 15 deletions.
23 changes: 8 additions & 15 deletions src/main/java/com/ibm/northstar/SystemDependencyGraph.java
Original file line number Diff line number Diff line change
Expand Up @@ -227,21 +227,6 @@ public static String construct(
IAnalysisCacheView cache = new AnalysisCacheImpl(AstIRFactory.makeDefaultFactory(),
options.getSSAOptions());

// set cyclomatic complexity for callables in the symbol table
int numClasses = cha.getNumberOfClasses();
for (Iterator<IClass> classIter = cha.iterator(); classIter.hasNext(); ) {
IClass cls = classIter.next();
for (IMethod method: cls.getAllMethods()) {
Callable callable = getCallableFromSymbolTable(method).getRight();
if (callable != null) {
IR ir = cache.getIR(method);
if (ir != null) {
callable.setCyclomaticComplexity(getCyclomaticComplexity(ir));
}
}
}
}

// Build call graph
Log.info("Building call graph.");

Expand All @@ -264,6 +249,14 @@ public static String construct(
Log.done("Finished construction of call graph. Took "
+ Math.ceil((double) (System.currentTimeMillis() - start_time) / 1000) + " seconds.");

// set cyclomatic complexity for callables in the symbol table
callGraph.forEach(cgNode -> {
Callable callable = getCallableFromSymbolTable(cgNode.getMethod()).getRight();
if (callable != null) {
callable.setCyclomaticComplexity(getCyclomaticComplexity(cgNode.getIR()));
}
});

// Build SDG graph
Log.info("Building System Dependency Graph.");
SDG<? extends InstanceKey> sdg = new SDG<>(
Expand Down

0 comments on commit 8e65f4a

Please sign in to comment.