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

Private variable incorrectly flagged unused

Open lievendf opened this issue 7 years ago • 2 comments

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...

lievendf avatar Oct 12 '18 14:10 lievendf

Reproduced !

gquerret avatar Oct 14 '18 16:10 gquerret

Rule applies to variables / properties for now, not to methods

gquerret avatar Oct 14 '18 16:10 gquerret