dgryski / semgrep-go

Go rules for semgrep and go-ruleguard
MIT License
457 stars 37 forks source link

add check for 'if x == nil && len(x) > 0' #67

Closed dmitris closed 5 months ago

dmitris commented 5 months ago

PR adds a check for a pattern from a recent PR review - with x being a slice (or map), an erroneous check for x == nil && len(x) > 0, two contradictory conditions that cannot be true at the same time, since the length of a nil slice or map is defined to be 0: