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
}
This diagnostic rule is classified as:
Was this page helpful?
Your message has been sent. We will email you at
If you do not see the email in your inbox, please check if it is filtered to one of the following folders: