mirror of
https://github.com/mgechev/revive.git
synced 2025-01-10 03:17:11 +02:00
24 lines
374 B
Go
24 lines
374 B
Go
|
// Test of return+else warning.
|
||
|
|
||
|
// Package pkg ...
|
||
|
package pkg
|
||
|
|
||
|
import "log"
|
||
|
|
||
|
func f(x int) bool { // MATCH /function f has cyclomatic complexity 4/
|
||
|
if x > 0 && true || false {
|
||
|
return true
|
||
|
} else {
|
||
|
log.Printf("non-positive x: %d", x)
|
||
|
}
|
||
|
return false
|
||
|
}
|
||
|
|
||
|
func g(f func() bool) string {
|
||
|
if ok := f(); ok {
|
||
|
return "it's okay"
|
||
|
} else {
|
||
|
return "it's NOT okay!"
|
||
|
}
|
||
|
}
|