SA0168: Unnecessary assignments

Function

Determines assignments to variables that have no effects in the code.

Reason

If several values are assigned to a variable without the variable being evaluated between the assignments, the first assignments do not have any effect on the program.

Importance

Low

Sample:

PROGRAM MAIN
VAR
    nVar1   : DWORD;
    nVar2   : DWORD;
END_VAR
nVar1 := 1;
 
IF nVar2 > 100 THEN
    nVar2 := 0;
    nVar2 := nVar2 + 1;
END_IF
 
nVar1 := 2;                      // => SA0168