sonar-openedge
sonar-openedge copied to clipboard
Variable is read but never assigned not triggered when variable assigned /after/ read
The 'variable is read but never assigned' rule does not detect the following smell:
DEFINE VARIABLE foo AS LOGICAL NO-UNDO.
IF foo THEN
MESSAGE "bar":u.
ELSE
foo = TRUE.
When the assignment to foo is removed it works fine.
The rule should be checking that the first use of the variable is after the first assign of the variable.
Agree it should be detected, but this level of granularity is not available yet. We'd need to have better flow control to detect this case.
Code flow information is now available in the parse tree, so enhancement can now be implemented.