threads != nil && slice.NoneOf(threads, func(i int) bool {
return strings.HasPrefix(name, threads[i])
})
; nil check may not be enough, check for len138 for _, usage := range usages {
139 name := usage.GetKey()
140 value := usage.GetValue()
141 if threads != nil && slice.NoneOf(threads, func(i int) bool {142 return strings.HasPrefix(name, threads[i])
143 }) {
144 continue
Some conditions become unsafe when not exhaustive. It is recommended to introduce complete condition checking to avoid bug risks.
In the following example, the slice xs
may be of zero length, but
not necessarily nil
(say, when xs := make([]SomeType, 0)
). Hence, the second
part of the condition will panic if there are no elements yet.
xs != nil && xs[0] != nil
len(xs) != 0 && xs[0] != nil