mirror of
https://github.com/github/codeql.git
synced 2025-12-16 16:53:25 +01:00
19 lines
596 B
Plaintext
19 lines
596 B
Plaintext
/**
|
|
* @name Incomplete switch over enum
|
|
* @description A switch statement of enum type should explicitly reference each
|
|
* of the members of that enum.
|
|
* @severity warning
|
|
* @kind problem
|
|
* @id go/examples/incomplete-switch
|
|
*/
|
|
|
|
import go
|
|
|
|
from ExpressionSwitchStmt ss, DeclaredConstant c, DefinedType t
|
|
where
|
|
t.getUnderlyingType() instanceof IntegerType and
|
|
t = ss.getExpr().getType() and
|
|
c.getType() = t and
|
|
forall(CaseClause case | case = ss.getACase() | not case = c.getAReference().getParent())
|
|
select ss, "This switch statement is not exhaustive: missing $@", c, c.getName()
|