SA0090: Return statement before end of functionPermalink

Detects whether or not the ‎RETURN‎ statement is not the last statement in a function, method, property, or program.

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

FUNCTION FUN : DINT
VAR_INPUT
	bTest : BOOL;
END_VAR

IF bTest THEN
	RETURN;
END_IF
FUN := 99;

--> SA0090: Return statement before end of function