This rule detects when a method argument is reassigned in the method body but is not passed by reference.
Two possibilities exist:
While this is a distinct possibility, it is generally considered to be bad practice. It is advised that a dedicated variable be created for this purpose.
For instance, instead of doing:
Method m(arg as %String) as %String
{
// modify arg, then...
return arg
}
write:
Method m(arg as %String) as %String
{
#dim x as %String = arg
// modify x, then...
return x
}
In this case, modify the prototype to add either the ByRef or Output modifier. For instance, replace:
Method m(arg as %String)
{
// modify arg; modifications NOT visible by the caller
}
with:
Method m(ByRef arg as %String)
{
// modify arg; now modifications are visible by the caller
}