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

Default access mode on getter/setter should not be specified

Open cverbiest opened this issue 6 years ago • 3 comments

getters and setters should not specify the access mode if it is the same as the property.

Following code would violate this rule

    define public property ProfilerCoverage as logical no-undo initial yes
    public get.
    public set.

    define public property ProfilerBusy as logical no-undo initial yes
    public get.
    private set.


The correction would be

    define public property ProfilerCoverage as logical no-undo initial yes
        get.
        set.

    define public property ProfilerBusy as logical no-undo initial yes
        get.
        private set.

cverbiest avatar Oct 25 '19 10:10 cverbiest

Our coding style is the opposite. An option to force access mode would be nice.

movedoa avatar Feb 05 '20 17:02 movedoa

@movedoa this is the opposite of my request. I think it would be confusing if this was enforced by the same rule, even though the code behind the rules would probably be very similar. The documentation of the rule would be confusing if it was advocating two opposite styles at the same time.

cverbiest avatar Feb 08 '20 16:02 cverbiest

i think with the right name this could be one rule without causing confusion.

PreferedAccessModeStyle with the setting "Implicit/Explicit" for example.

But if i get my own rule i don't care too much how it gets implemented ;-)

movedoa avatar Feb 08 '20 17:02 movedoa