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
324
324
.reduce (0 , Integer ::sum );
325
325
int conditionalExprCount = callableDeclaration .findAll (ConditionalExpr .class ).size ();
326
326
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 ;
329
328
}
330
329
331
330
/**
Original file line number Diff line number Diff line change 23
23
import com .ibm .wala .ipa .callgraph .impl .DefaultEntrypoint ;
24
24
import com .ibm .wala .ipa .cha .IClassHierarchy ;
25
25
import com .ibm .wala .ssa .IR ;
26
+ import com .ibm .wala .ssa .ISSABasicBlock ;
26
27
import com .ibm .wala .ssa .SSAConditionalBranchInstruction ;
27
28
import com .ibm .wala .ssa .SSASwitchInstruction ;
28
29
import com .ibm .wala .types .ClassLoaderReference ;
@@ -96,7 +97,11 @@ public static int getCyclomaticComplexity(IR ir) {
96
97
int switchBranchCount = Arrays .stream (ir .getInstructions ())
97
98
.filter (inst -> inst instanceof SSASwitchInstruction )
98
99
.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 ;
100
105
}
101
106
102
107
public static Pair <String , Callable > getCallableFromSymbolTable (IMethod method ) {
You can’t perform that action at this time.
0 commit comments