sonar-openedge icon indicating copy to clipboard operation
sonar-openedge copied to clipboard

Variable is read but never assigned not triggered when variable assigned /after/ read

Open stefandrissen opened this issue 7 years ago • 2 comments

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.

stefandrissen avatar Jan 02 '19 07:01 stefandrissen

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.

gquerret avatar Jan 02 '19 12:01 gquerret

Code flow information is now available in the parse tree, so enhancement can now be implemented.

gquerret avatar Jul 19 '21 07:07 gquerret