V8012. A function always returns the same value. Consider inspecting the program's logic.
The analyzer detected a function that returns the same value on all execution paths. Such code is suspicious and may indicate an error. Most likely, the function should return different values.
The example:
func IsEven(a int) bool {
if a % 2 == 1 {
return false
}
return false
}
The IsEven function always returns false for any passed arguments. To fix this error, the return values need to be changed.
The fixed code version:
func IsEven(a int) bool {
if a % 2 == 1 {
return false
}
return true
}
After the fix, the code can be simplified:
func IsEven(a int) bool {
return a % 2 == 0
}