sonar-openedge
sonar-openedge copied to clipboard
No delete of input parameter
Hello,
IMHO the creator of an object should be responsable for the lifecycle of an object.
Example:
METHOD VOID doNothing(oObject AS Progress.Lang.Object):
IF VALID-OBJECT(oObject) THEN DO:
DELETE OBJECT oObject. // this should generate a bug
END.
END. METHOD.
// more complex example
DEFINE VARIABLE myInputParameter AS Progress.Lang.Object NO-UNDO.
CONSTRUCTOR(oObject AS Progress.Lang.Object):
myInputParameter = oObject.
END CONSTRUCTOR.
DESTRUCTOR():
DELETE OBJECT myInputParameter. // this should generate a bug
END DESTRUCTOR.
I agree , unless the method is called DeleteObject ;-) . So there should be an option to suppress issue.
On the other hand, if the parameter is a table-handle, then it 's a bug (memory leak) when it does not get deleted at the end of the procedure. Although the exact rules in which cases delete is required / not required are not totally clear to me (because it is also not totally clear in which cases Progress performs a deep-copy when you pass a handle or pointer).