Toad World® Forums

Code Analysis - Rule 2131: Use CONSTANT keyword wherever possible

Code analysis does not realize that variables used as out-parameter cannot be defined as constants:

CREATE PACKAGE BODY test_package AS
PROCEDURE test_out( out_param OUT PLS_INTEGER ) AS
BEGIN
out_param := 1;
END test_out;

PROCEDURE test_proc AS
** my_val PLS_INTEGER; – Rule 2131: Use CONSTANT keyword wherever possible.**
BEGIN
test_out( my_val );
END test_proc;
END test_package;

I changed the behavior such that variables won’t be flagged anymore if they are used as program unit arguments.

In addition, variables declared at some scope will now be searched only in sibling and nested text, rather than finding them in the whole text. This should reduce the number of false negatives.

Thanks for your feedback! (QP-1512)

Thanks! I will try this when I update my beta next time.

I’m “tracking” my open issues using the report “Open Questions”, and since you suggested an answer, it does not show there any more. Would it be OK for you if I “un-accepted” your answer for now so that I won’t forget it when testing later?

Done. Anyway, it’s just an XPath expression change. You can change the rule using the one below. It’ll go into the Rule Universe.

//VAR_DECL [not(…//ASSIGN/LHS/QNAME/@value = QNAME/@value)]
[not(…//INTO_LIST/QNAME/@value = QNAME/@value)]
[not(…//PARAM/QNAME/@value = QNAME/@value)]
/QNAME