SA0011: Useless declarationsPermalink

Detects structures or enumerations with only one component

Justification: This kind of declaration can be confusing for the reader. A structure with only one element can be replaced by an alias type. An enumeration with only one element can be replaced by an constant.

PLCopen rule: CP22 / CP24

Importance: Low

Example

TYPE SingleStruct :
STRUCT
	iPart : INT;
END_STRUCT
END_TYPE

TYPE myUnion :
UNION
	lrValue : LREAL;
END_UNION
END_TYPE

TYPE SingleEnum :
(
	OnlyOne := 1
);
END_TYPE

--> Useless declaration 'SingleStruct'
--> Useless declaration 'myUnion'
--> Useless declaration 'SingleEnum'