Skip to content

Commit 8e65f4a

Browse files
authored
Merge pull request #16 from sinha108/main
Updated cyclomatic complexity computation to run on CG nodes
2 parents 23dbbdd + c500e50 commit 8e65f4a

File tree

1 file changed

+8
-15
lines changed

1 file changed

+8
-15
lines changed

src/main/java/com/ibm/northstar/SystemDependencyGraph.java

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -227,21 +227,6 @@ public static String construct(
227227
IAnalysisCacheView cache = new AnalysisCacheImpl(AstIRFactory.makeDefaultFactory(),
228228
options.getSSAOptions());
229229

230-
// set cyclomatic complexity for callables in the symbol table
231-
int numClasses = cha.getNumberOfClasses();
232-
for (Iterator<IClass> classIter = cha.iterator(); classIter.hasNext(); ) {
233-
IClass cls = classIter.next();
234-
for (IMethod method: cls.getAllMethods()) {
235-
Callable callable = getCallableFromSymbolTable(method).getRight();
236-
if (callable != null) {
237-
IR ir = cache.getIR(method);
238-
if (ir != null) {
239-
callable.setCyclomaticComplexity(getCyclomaticComplexity(ir));
240-
}
241-
}
242-
}
243-
}
244-
245230
// Build call graph
246231
Log.info("Building call graph.");
247232

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

252+
// set cyclomatic complexity for callables in the symbol table
253+
callGraph.forEach(cgNode -> {
254+
Callable callable = getCallableFromSymbolTable(cgNode.getMethod()).getRight();
255+
if (callable != null) {
256+
callable.setCyclomaticComplexity(getCyclomaticComplexity(cgNode.getIR()));
257+
}
258+
});
259+
267260
// Build SDG graph
268261
Log.info("Building System Dependency Graph.");
269262
SDG<? extends InstanceKey> sdg = new SDG<>(

0 commit comments

Comments
 (0)