diff --git a/testdata/src/a/a.go b/testdata/src/a/a.go index 1585b2d..3f9d854 100644 --- a/testdata/src/a/a.go +++ b/testdata/src/a/a.go @@ -99,7 +99,7 @@ func ComplexLogicalSeq5(a, b, c, d, e, f bool) bool { // want "cognitive complex return a && b && (c && d || e || f) // +1 for `&&` sequence, +2 for `&&` `||` sequence in parentheses } // total complexity = 3 -func ExprFunc(a, b, c any) bool { // want "cognitive complexity 2 of func ExprFunc is high \\(> 0\\)" +func ExprFunc(a, b, c interface{}) bool { // want "cognitive complexity 2 of func ExprFunc is high \\(> 0\\)" if a != nil || b != nil || c != nil { // +1 for `if`, +1 for `||` chain return false } @@ -107,7 +107,7 @@ func ExprFunc(a, b, c any) bool { // want "cognitive complexity 2 of func ExprFu return true } // total complexity = 2 -func VarFunc(a, b, c any) bool { // want "cognitive complexity 2 of func VarFunc is high \\(> 0\\)" +func VarFunc(a, b, c interface{}) bool { // want "cognitive complexity 2 of func VarFunc is high \\(> 0\\)" na := a != nil nb := b != nil nc := c != nil diff --git a/testdata/src/b/b.go b/testdata/src/b/b.go index 2bd3093..b176ec2 100644 --- a/testdata/src/b/b.go +++ b/testdata/src/b/b.go @@ -75,6 +75,41 @@ func ComplexLogicalSeq2(a, b, c, d, e, f bool) string { return "not ok" } // total complexity = 3 +func ComplexLogicalSeq3(a, b, c, d, e, f bool) string { + if a && (b && c) { // +1 for `if`, +1 for each `&&` chain + return "ok" + } + + return "not ok" +} // total complexity = 3 + +func ComplexLogicalSeq4(a, b, c, d, e, f bool) bool { + return a && b && c || d || e && f // +3 for changing sequence of `&&` `||` `&&` +} // total complexity = 3 + +func ComplexLogicalSeq5(a, b, c, d, e, f bool) bool { + return a && b && (c && d || e || f) // +1 for `&&` sequence, +2 for `&&` `||` sequence in parentheses +} // total complexity = 3 + +func ExprFunc(a, b, c interface{}) bool { + if a != nil || b != nil || c != nil { // +1 for `if`, +1 for `||` chain + return false + } + + return true +} // total complexity = 2 + +func VarFunc(a, b, c interface{}) bool { + na := a != nil + nb := b != nil + nc := c != nil + if na || nb || nc { // +1 for `if`, +1 for `||` chain + return false + } + + return true +} // total complexity = 2 + func GetWords(number int) string { switch number { // +1 case 1: