-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
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
with identical then
and else
branches
#2537
Comments
yes but one will match a hostname and the other will not. how do you propose to make it better? |
As is written, the value of
In general, if both branches do the same, the full if-statement can be safely replaced with any of its branches, therefore if strings.Contains(uri.Host, "visualstudio.com") {
owner = strings.Split(uri.Host, ".")[0]
} else if strings.Contains(uri.Host, "dev.azure.com") {
owner = strings.Split(uri.Path, "/")[1]
} else {
owner = strings.Split(uri.Path, "/")[1] // to support owner for self hosted
} can be rewritten as if strings.Contains(uri.Host, "visualstudio.com") {
owner = strings.Split(uri.Host, ".")[0]
} else {
owner = strings.Split(uri.Path, "/")[1]
} Warn: accessing the second element of the result of a |
I C what you mean, yes , that could be improved, are you willing to send a PR over? |
Yes, sure, you can assign the issue to me |
I can't assign to you, it does not let me because you are not in the maintainers list |
In the following code, both control branches do the same (i.e.
owner = strings.Split(uri.Path, "/")[1]
)atlantis/server/events/event_parser.go
Lines 926 to 930 in 2cd8bd9
Found by revive (rule
identical-branches
)The text was updated successfully, but these errors were encountered: