sonar-openedge
sonar-openedge copied to clipboard
Invalid number of parameters in SUBSTITUTE statement doesnt report missing substitution parameters
V 2.24 The rule doesnt seem to check if all variables are actually used in the base-string.
DEFINE VARIABLE lcFoo AS CHARACTER NO-UNDO.
/* 2 parameter(s) expected by SUBSTITUTE function, but 3 provided */
lcFoo = SUBSTITUTE("&1 &2":U, "1":U, "2":U, "3":U).
/* No issue reported, even though &2 is missing */
lcFoo = SUBSTITUTE("&1 &3":U, "1":U, "2":U, "3":U).
The very first versions of this rule (not sure if that was part of the public release) reported those issues, but it was a bit too noisy on various codebases. I can re-introduce the check if you see enough value.
I think this is never intentional and often a bug or at least a code smell. I noticed it when a value in a log file was not what i expected but this could lead to bigger hard to find problems.