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

new rule for unused parameter of implemented method

Open clement-brodu opened this issue 3 years ago • 2 comments

Hello,

Here is my case:

INTERFACE IGetLabel:

    METHOD PUBLIC CHARACTER GetLabel( INPUT pCode AS CHARACTER ).

END INTERFACE.
CLASS MyObject IMPLEMENTS IGetLabel:

    METHOD PUBLIC CHARACTER GetLabel( INPUT pCode AS CHARACTER ):     
       RETURN "Hello".
    END METHOD.

END CLASS.

In MyObject, the pCode parameter is not used in the method (it's a bug in my code).

Usually, "Unused parameter should be removed" rule show me this error and I can fix or ignore it. But because this method come from my interface, this rule doesn't show any error (that's legit).

May be we should have a new rule for unused parameters of inherited/implemented method ?

Thanks,

clement-brodu avatar Jan 19 '22 09:01 clement-brodu

This case is specifically excluded from the existing rule, as there's nothing you can do if you don't have any usage for this variable. It could technically be possible to have a separate rule for that, but to my mind, it will report way too many false positives.

gquerret avatar Jan 20 '22 13:01 gquerret

For me, a separate rule is the best choice. The name could be "Unused parameter for implemented method"

False positive could be ignored with {&_proparse_ prolint-nowarn(varusage)}. But for me, if the parameter is not used, it's probably an error.

And if people are not interested with this, they could disable the rule.

clement-brodu avatar Jan 20 '22 13:01 clement-brodu