CodeQL queries 1.24

Skip to end of metadata
Go to start of metadata

Finds switch statements with a missing enum constant case and no default case

import java

from SwitchStmt switch, EnumType enum, EnumConstant missing
where
  switch.getExpr().getType() = enum and
  missing.getDeclaringType() = enum and
  not switch.getAConstCase().getValue() = missing.getAnAccess() and
  not exists(switch.getDefaultCase())
select switch