SA0012: Variables which could be declared as constants
Function | Determines variables that are not subject to write access and therefore could not be declared as constants. |
Reason | If a variable is only written at the declaration point and is otherwise only used in read mode, the static analysis assumes that the variable is to remain unchanged. Declaration as a constant means that the variable is checked for changes in the event of program modifications. Plus, declaration as a constant may lead to faster code. |
Importance | Low |
Sample:
PROGRAM MAIN
VAR
nSample : INT := INT#17;
nVar : INT;
END_VARnVar := nVar + nSample; // => SA0012