We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
If there is a chain of if/else, suggest switch as alternative.
These two functions should trigger the warning:
func cond1(x int) string { if x == 0 { return "zero" } else if x < 0 { return "negative" } else { return "positive" } } func cond2(x int) string { if x == 0 { return "zero" } else if x < 0 { return "negative" } return "positive" }
Suggested alternative is:
func condSuggested(x int) string { switch { case x == 0: return "zero" case x < 0: return "negative" default: return "positive" } }
TODO: find out if if/else is ever more readable or wanted instead of switch. Maybe init statements can complicate things.
if/else
The text was updated successfully, but these errors were encountered:
lint: add elseif checker v1
b4313d6
Fixes #77
lint: add elseif checker v1 (#80)
ed22ee5
quasilyte
No branches or pull requests
If there is a chain of if/else, suggest switch as alternative.
These two functions should trigger the warning:
Suggested alternative is:
TODO: find out if
if/else
is ever more readable or wanted instead of switch.Maybe init statements can complicate things.
The text was updated successfully, but these errors were encountered: