github.com/songshiyun/revive@v1.1.5-0.20220323112655-f8433a19b3c5/testdata/cyclomatic.go (about) 1 // Test of cyclomatic complexity. 2 3 // Package pkg ... 4 package pkg 5 6 import "log" 7 8 func f(x int) bool { // MATCH /function f has cyclomatic complexity 4 (> max enabled 1)/ 9 if x > 0 && true || false { 10 return true 11 } else { 12 log.Printf("non-positive x: %d", x) 13 } 14 return false 15 } 16 17 func g(f func() bool) string { // MATCH /function g has cyclomatic complexity 2 (> max enabled 1)/ 18 if ok := f(); ok { 19 return "it's okay" 20 } else { 21 return "it's NOT okay!" 22 } 23 }