sonar-openedge
sonar-openedge copied to clipboard
Private variable incorrectly flagged unused
Private members of a class are "class private" in ABL (vs "object/instance private"). This means a Class "Person" can e.g. have a private variable "Name" that is accessible from outside the instance in this case:
CLASS Person:
DEFINE PRIVATE VARIABLE Name AS CHARACTER NO-UNDO.
DEFINE PRIVATE VARIABLE Mother AS Person NO-UNDO.
METHOD PUBLIC VOID CreateMother(Name AS CHARACTER):
Mother = NEW Person().
Mother:Name = Name. /* Works even though this is private! */
END METHOD.
METHOD PUBLIC VOID ShowMotherName():
MESSAGE Mother:Name
VIEW-AS ALERT-BOX.
Mother:ShowPrivate(). /* Works even though this is private! */
END METHOD.
METHOD PRIVATE VOID ShowPrivate():
MESSAGE "Private!"
VIEW-AS ALERT-BOX.
END METHOD.
END CLASS.
The Name variable is incorrectly flagged as unused. No warning is shown for the ShowPrivate() method though...
Reproduced !
Rule applies to variables / properties for now, not to methods