Bound check after create
bound_check_after_create
Description
Finds IF r IS BOUND / IS NOT BOUND directly after r was created
Extended Information
Reports IF r IS BOUND. and IF r IS NOT BOUND. after CREATE OBJECT r., r = NEW ...( ). or
DATA(r) = NEW ...( ). in the same block, when all of the following hold:
* r is a local variable whose address is never taken, or an attribute: attr, me->attr or local->attr
* CREATE OBJECT has no EXCEPTIONS addition and no dynamic type, NEW is not followed by a method call
* every statement in between is a direct statement of the same block, not a nested structure
* a local r is not written in between
* for an attribute: no method, function or form call and no constructor in between, the local before ->
is not written, and no write in between can change the attribute: no write to an attribute with the
same name, to a field symbol, via ->*, or to a parameter passed by reference
The quick fix keeps the IS BOUND branch and removes the rest, or removes the IS NOT BOUND branch;
nothing is reported if a removed branch declares data that is used outside of it.
Objects with syntax errors, macros or unknown statements are skipped, as are procedures with dynamic code,
INCLUDE, test seams, enhancements or native SQL. No release requirement.