sonar-openedge
sonar-openedge copied to clipboard
Flag if valid-handle( a ) then delete object b.
Since no-error is frowned upon by one of the rules, we've been changing a lot of delete object a no-error
to:
if valid-handle( a ) then
delete object a.
And before you know it something like the following happens:
if valid-handle( a ) then
delete object a.
if valid-handle( a ) then
delete object b.
With, as a result, object b leaking.
Optionally some smartness could be included for table-handles:
if valid-handle( hb ) then
delete object hb:table-handle.
Maybe an "unused valid object" rule ? Fired whenever an object is checked for validity without being used.
If created I think valid-handle and valid-object should be treated equally.
cave-at, usage could be within the same expression. e.g. `if valid-handle(hb) and hb:available then ...
In my case both objects were used, only the delete of one was conditional due to the 'typo' checking the wrong variable. ie I had a massive memory leak (these were x-noderefs)
With my suggestion the unused valid object rule would flag object a on the second if.
delete object a.
/* this if get flagged */ if valid-handle( a ) then
delete object b.
It is the if statement that gets flagged because it use a valid-handle test on an object that is not used in the then block.