SA0076: Missing enumeration constantPermalink

Detects whether or not an enumeration variable is used as a condition and not all enumeration values are treated as ‎CASE‎ branches

Justification: Defensive programming requires the processing of all possible values of an enumeration. If an action is not required for a particular enumeration value, then you should add a comment to indicate this explicitly. It is then clear to the reader of the code that the value was not simply forgotten.

Importance: Low

Example

TYPE My_Enum :
(
	red := 1, blue := 2, green := 3, black := 4
);
END_TYPE

PROGRAM PLC_PRG
VAR
	iVar : My_Enum;
	xTemp : BOOL;
END_VAR
iVar := My_Enum.black;

CASE iVar OF
	My_Enum.red:
		xTemp := FALSE;
	My_Enum.blue, My_Enum.green:
		xTemp := TRUE;
	ELSE
		xTemp := NOT xTemp;
END_CASE

--> SA0076: Missing enumeration constant 'black' in CASE statement