-
Notifications
You must be signed in to change notification settings - Fork 304
Closed
Description
Is your feature request related to a problem? Please describe.
A simplified code is as follows:
func TestA(t *testing.T) {
tests := make([]int, 100)
for i := range tests {
println("i: ", i)
if i == 0 {
t.Fatal("i == 0") // MATCH /unreachable code after this statement/
println("unreachable")
continue
}
if i == 1 {
t.Fatalf("i:%d", i) // MATCH /unreachable code after this statement/
println("unreachable")
continue
}
if i == 2 {
t.FailNow() // MATCH /unreachable code after this statement/
println("unreachable")
continue
}
/* Skip is used to temporarily skip tests. The code following it is intentionally unreachable.
if i == 3 {
t.Skip("i == 3") // MATCH /unreachable code after this statement/
println("unreachable")
continue
}
if i == 4 {
t.Skipf("i:%d", i) // MATCH /unreachable code after this statement/
println("unreachable")
continue
}
if i == 5 {
t.SkipNow() // MATCH /unreachable code after this statement/
println("unreachable")
continue
}
*/
}
}
The actual code can be seen in k8s https://github.com/kubernetes/kubernetes/pull/111228/files#diff-b5b428649cab55e247eddbd00bc278c628c40ed524814ffe9dede44af19ee3b5R1899 and etcd etcd-io/etcd#14235
Describe the solution you'd like
I wish there was a way to detect them
Describe alternatives you've considered
Goland can detect them, but has bug in some situation, see https://youtrack.jetbrains.com/issue/GO-13383
go vet cant detect this. Some discussions are here golang/go#53968
Additional context
None
Metadata
Metadata
Assignees
Labels
No labels