File tree Expand file tree Collapse file tree 2 files changed +7
-3
lines changed
src/main/java/com/ibm/cldk Expand file tree Collapse file tree 2 files changed +7
-3
lines changed Original file line number Diff line number Diff line change @@ -324,8 +324,7 @@ private static int getCyclomaticComplexity(CallableDeclaration callableDeclarati
324324 .reduce (0 , Integer ::sum );
325325 int conditionalExprCount = callableDeclaration .findAll (ConditionalExpr .class ).size ();
326326 int catchClauseCount = callableDeclaration .findAll (CatchClause .class ).size ();
327- int cyclomaticComplexity = ifStmtCount + loopStmtCount + switchCaseCount + conditionalExprCount + catchClauseCount + 1 ;
328- return cyclomaticComplexity ;
327+ return ifStmtCount + loopStmtCount + switchCaseCount + conditionalExprCount + catchClauseCount + 1 ;
329328 }
330329
331330 /**
Original file line number Diff line number Diff line change 2323import com .ibm .wala .ipa .callgraph .impl .DefaultEntrypoint ;
2424import com .ibm .wala .ipa .cha .IClassHierarchy ;
2525import com .ibm .wala .ssa .IR ;
26+ import com .ibm .wala .ssa .ISSABasicBlock ;
2627import com .ibm .wala .ssa .SSAConditionalBranchInstruction ;
2728import com .ibm .wala .ssa .SSASwitchInstruction ;
2829import com .ibm .wala .types .ClassLoaderReference ;
@@ -96,7 +97,11 @@ public static int getCyclomaticComplexity(IR ir) {
9697 int switchBranchCount = Arrays .stream (ir .getInstructions ())
9798 .filter (inst -> inst instanceof SSASwitchInstruction )
9899 .map (inst -> ((SSASwitchInstruction ) inst ).getCasesAndLabels ().length ).reduce (0 , Integer ::sum );
99- return conditionalBranchCount + switchBranchCount + 1 ;
100+ Iterable <ISSABasicBlock > iterableBasicBlocks = ir ::getBlocks ;
101+ int catchBlockCount = (int ) StreamSupport .stream (iterableBasicBlocks .spliterator (), false )
102+ .filter (ISSABasicBlock ::isCatchBlock )
103+ .count ();
104+ return conditionalBranchCount + switchBranchCount + catchBlockCount + 1 ;
100105 }
101106
102107 public static Pair <String , Callable > getCallableFromSymbolTable (IMethod method ) {
You can’t perform that action at this time.
0 commit comments