Skip to content

Commit f8d6e2a

Browse files
Alessandro BiancoAlessandro Bianco
authored andcommitted
Added default threshold configuration for the CyclomaticComplexityCheck;
Handled the case of Null<Null<Expr>> leading to a RTE;
1 parent 39ff437 commit f8d6e2a

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

checkstyle/checks/CyclomaticComplexityCheck.hx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@ using Lambda;
1313
@desc("McCabe simplified cyclomatic complexity check")
1414
class CyclomaticComplexityCheck extends Check {
1515

16-
public var thresholds:Array<Threshold>;
16+
public var thresholds:Array<Threshold> = [
17+
{ severity : "WARNING", complexity : 11 },
18+
{ severity : "ERROR", complexity : 21 }
19+
];
1720

1821
override function _actualRun() {
1922
_checker.ast.decls.map(function(type:TypeDecl):Null<Definition<ClassFlag, Array<Field>>> {
@@ -51,7 +54,7 @@ class CyclomaticComplexityCheck extends Check {
5154

5255
// This would not pass the cyclomatic complexity test.
5356
function evaluateExpr(e:Expr):Int {
54-
if (e == null) {
57+
if (e == null || e.expr == null) {
5558
return 0;
5659
}
5760
return switch(e.expr) {

run.n

-2.65 KB
Binary file not shown.

0 commit comments

Comments
 (0)