SA0090: POUs should have a only one exit point
Function | Detects code positions where the RETURN statement is not the last statement in a function, method, property or program. It also recognizes places where there is a RETURN within an IF branch. |
Reason | A RETURN in the code leads to poorer maintainability, testability and readability of the code. A RETURN in the code is easily overlooked. You must insert code, which should be executed in any case when a function exits, before each RETURN. This is often overlooked. |
Importance | Medium |
PLCopen rule | CP14 |
Sample:
FUNCTION F_TestFunction : DINT
VAR_INPUT
bTest : BOOL;
END_VARIF bTest THEN
RETURN; // => SA0090
END_IF
F_TestFunction := 99;