SA0090: POUs shall have a single point of exit
Detects code locations where the RETURN statement is not the last statement in a function, method, property, or program. Locations where a RETURN exists within an IF branch are also detected.
Justification: A RETURN in the code results in worse maintainability, testability, and readability of the code. A RETURN in the code is easily overlooked. Before each RETURN, it is often forgotten to insert code that should always be executed when exiting a function.
Importance: Medium
PLCopen rule: CP14
Example 87. Example
FUNCTION SA0090: DINT
VAR_INPUT
bTest : BOOL;
END_VARIF bTest THEN
RETURN;
END_IF
SA0090 := 99;Output in the Messages view:
SA0090: POUs shall have a single point of exit