Riverside-Software / sonar-openedge

CABL (Code Analyzer for ABL in SonarQube) - ABL ANTLR4 Parser
https://riverside-software.fr
GNU Lesser General Public License v3.0
62 stars 25 forks source link

MethodHasTooManyParameters false positive on main block of a class caused by event parameters #1136

Open ccecvb opened 3 weeks ago

ccecvb commented 3 weeks ago

I activate the rule yesterday, behaviour could be present for longer.

Main block has 18 parameters, which is greater than 8 authorized

image At first, I thought it was the usings causing this.

It turns out it's the event parameters that are counted as main block parameters.

/*------------------------------------------------------------------------
    File        : ToomanyParams
  ----------------------------------------------------------------------*/
block-level on error undo, throw.

class ToomanyParams:

    define public event Event1 signature void ( input sender as Progress.Lang.Object, input e as Progress.Lang.Object ).
    define public event Event2 signature void ( input sender as Progress.Lang.Object, input e as Progress.Lang.Object ).
    define public event Event3 signature void ( input sender as Progress.Lang.Object, input e as Progress.Lang.Object ).
    define public event Event4 signature void ( input sender as Progress.Lang.Object, input e as Progress.Lang.Object ).
    define public event Event5 signature void ( input sender as Progress.Lang.Object, input e as Progress.Lang.Object ).
    define public event Event6 signature void ( input sender as Progress.Lang.Object, input e as Progress.Lang.Object ).
    define public event Event7 signature void ( input sender as Progress.Lang.Object, input e as Progress.Lang.Object ).
    define public event Event8 signature void ( input sender as Progress.Lang.Object, input e as Progress.Lang.Object ).
    define public event Event9 signature void ( input sender as Progress.Lang.Object, input e as Progress.Lang.Object ).

end class.
gquerret commented 3 weeks ago

Confirmed, the parameters of the event are incorrectly attached to the main scope.