Skip to content

Commit 07e0618

Browse files
committed
checkstyle warning cleanup
1 parent 1db3ce8 commit 07e0618

File tree

4 files changed

+39
-18
lines changed

4 files changed

+39
-18
lines changed

checkstyle/checks/CyclomaticComplexityCheck.hx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,16 +42,16 @@ class CyclomaticComplexityCheck extends Check {
4242

4343
function calculateComplexity(method:Target) {
4444
var complexity:Int = 1 + evaluateExpr(method.expr);
45-
45+
4646
var risk:Null<Threshold> = thresholds.filter(function(t:Threshold):Bool {
4747
return complexity >= t.complexity;
4848
}).pop();
49-
49+
5050
if (risk != null) {
5151
notify(method, complexity, risk);
5252
}
5353
}
54-
54+
5555
// This would not pass the cyclomatic complexity test.
5656
function evaluateExpr(e:Expr):Int {
5757
if (e == null || e.expr == null) {
@@ -65,9 +65,9 @@ class CyclomaticComplexityCheck extends Check {
6565
default : 0;
6666
};
6767
case ExprDef.EParenthesis(e) : evaluateExpr(e);
68-
case ExprDef.EObjectDecl(fields) :
69-
fields.map(function(f):Expr {
70-
return f.expr;
68+
case ExprDef.EObjectDecl(fields) :
69+
fields.map(function(f):Expr {
70+
return f.expr;
7171
}).fold(function(e:Expr, total:Int):Int {
7272
return total + evaluateExpr(e);
7373
}, 0);

checkstyle/checks/NestedForDepthCheck.hx

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,14 @@ import haxe.macro.Expr;
88
@desc("Max number of nested for blocks (default 1)")
99
class NestedForDepthCheck extends Check {
1010

11-
public var severity:String = "ERROR";
12-
public var max:Int = 1;
11+
public var severity:String;
12+
public var max:Int;
13+
14+
public function new() {
15+
super();
16+
severity = "ERROR";
17+
max = 1;
18+
}
1319

1420
override function _actualRun() {
1521
for (td in _checker.ast.decls) {
@@ -61,6 +67,7 @@ class NestedForDepthCheck extends Check {
6167
}
6268

6369
function _warnNestedForDepth(depth:Int, pos:Position) {
64-
logPos('Nested for depth is $depth (max allowed is ${max})', pos, Reflect.field(SeverityLevel, severity));
70+
logPos('Nested for depth is $depth (max allowed is ${max})',
71+
pos, Reflect.field(SeverityLevel, severity));
6572
}
66-
}
73+
}

checkstyle/checks/NestedIfDepthCheck.hx

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,14 @@ import haxe.macro.Expr;
88
@desc("Max number of nested if-else blocks (default 1)")
99
class NestedIfDepthCheck extends Check {
1010

11-
public var severity:String = "ERROR";
12-
public var max:Int = 1;
11+
public var severity:String;
12+
public var max:Int;
13+
14+
public function new() {
15+
super();
16+
severity = "ERROR";
17+
max = 1;
18+
}
1319

1420
override function _actualRun() {
1521
for (td in _checker.ast.decls) {
@@ -60,6 +66,7 @@ class NestedIfDepthCheck extends Check {
6066
}
6167

6268
function _warnNestedIfDepth(depth:Int, pos:Position) {
63-
logPos('Nested if-else depth is $depth (max allowed is ${max})', pos, Reflect.field(SeverityLevel, severity));
69+
logPos('Nested if-else depth is $depth (max allowed is ${max})',
70+
pos, Reflect.field(SeverityLevel, severity));
6471
}
65-
}
72+
}

checkstyle/checks/NestedTryDepthCheck.hx

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,14 @@ import haxe.macro.Expr;
88
@desc("Max number of nested try blocks (default 1)")
99
class NestedTryDepthCheck extends Check {
1010

11-
public var severity:String = "ERROR";
12-
public var max:Int = 1;
11+
public var severity:String;
12+
public var max:Int;
13+
14+
public function new() {
15+
super();
16+
severity = "ERROR";
17+
max = 1;
18+
}
1319

1420
override function _actualRun() {
1521
for (td in _checker.ast.decls) {
@@ -66,6 +72,7 @@ class NestedTryDepthCheck extends Check {
6672
}
6773

6874
function _warnNestedTryDepth(depth:Int, pos:Position) {
69-
logPos('Nested try depth is $depth (max allowed is ${max})', pos, Reflect.field(SeverityLevel, severity));
75+
logPos('Nested try depth is $depth (max allowed is ${max})',
76+
pos, Reflect.field(SeverityLevel, severity));
7077
}
71-
}
78+
}

0 commit comments

Comments
 (0)