Skip to content

Commit 003fa08

Browse files
committed
Add more test
1 parent f02a13c commit 003fa08

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

testdata/src/b/b.go

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import (
66
"io"
77
)
88

9+
type any interface{}
10+
911
func HelloWorld() string {
1012
_ = len("hello")
1113
return "Hello, World!"
@@ -75,6 +77,41 @@ func ComplexLogicalSeq2(a, b, c, d, e, f bool) string {
7577
return "not ok"
7678
} // total complexity = 3
7779

80+
func ComplexLogicalSeq3(a, b, c, d, e, f bool) string {
81+
if a && (b && c) { // +1 for `if`, +1 for each `&&` chain
82+
return "ok"
83+
}
84+
85+
return "not ok"
86+
} // total complexity = 3
87+
88+
func ComplexLogicalSeq4(a, b, c, d, e, f bool) bool {
89+
return a && b && c || d || e && f // +3 for changing sequence of `&&` `||` `&&`
90+
} // total complexity = 3
91+
92+
func ComplexLogicalSeq5(a, b, c, d, e, f bool) bool {
93+
return a && b && (c && d || e || f) // +1 for `&&` sequence, +2 for `&&` `||` sequence in parentheses
94+
} // total complexity = 3
95+
96+
func ExprFunc(a, b, c any) bool {
97+
if a != nil || b != nil || c != nil { // +1 for `if`, +1 for `||` chain
98+
return false
99+
}
100+
101+
return true
102+
} // total complexity = 2
103+
104+
func VarFunc(a, b, c any) bool {
105+
na := a != nil
106+
nb := b != nil
107+
nc := c != nil
108+
if na || nb || nc { // +1 for `if`, +1 for `||` chain
109+
return false
110+
}
111+
112+
return true
113+
} // total complexity = 2
114+
78115
func GetWords(number int) string {
79116
switch number { // +1
80117
case 1:

0 commit comments

Comments
 (0)