SA0025: Unqualified enumeration constantsPermalink

Detects enumeration constants for which a qualified name does not prepend the enumeration

Justification: Qualified access makes the code more readable and easier to maintain. Without forcing qualified variable names, an additional enumeration could be inserted when the program is extended. This enumeration contains a constant with the same name as an existing enumeration (see the example below: "red"). This would result in ambiguous access to this piece of code. We recommend to always use only enumerations with the {attribute 'qualified-only'}.

Importance: Medium

Example

TYPE COLOR
(red,green,blue);
END_TYPE

PROGRAM PLC_PRG
enumVar : COLOR;

enumVar := COLOR.red; // SA0025
enumVar := red;       // SA0025

--> SA0025: Enumeration constant 'red' not qualified