My golint returns this error message but i don't really understand what it means.
As in title:
return statements should not be cuddled if block has more than two lines (wsl)
my code is this:
func validateCountry(product models.Product, countries []models.Country) bool {
if !product.CountryCode.Valid {
return true
}
for _, country := range countries {
if country.Code == product.CountryCode.String {
return !country.Enabled && country.Deprecated
}
}
return false
}
What the linter does not like seems to be the last return false
.
I'm very confused, i didn't setup the linter in this codebase, and i don't really know how to either skip this rules or how to fix it.
This error means that, in your case, you need to put a blank line before any next return statement:
[empty line] <-- need this
return true
...
[empty line] <-- need this
return !country.Enabled && country.Deprecated
should not be cuddled
means there must be no code lines near the return statement.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With