abap-cleaner icon indicating copy to clipboard operation
abap-cleaner copied to clipboard

Feature Request: Point out NULL-reference

Open JoachimRees opened this issue 1 year ago • 1 comments

[ Up front: I'm not sure if ABAP Cleaner SHOULD help here, but I think it COULD, so I'm putting this up for consideration ]

If, in my code, I call a method of a locally defined object reference, BEFORE there was ever a WRITE/INSTANTION on the object reference, then this surely is a mistake (it will dump if executed).

Like un-used variables, ABAP Cleaner could point this out to me.

Example:

method do_something. 
data: not_used type any. 
data: lo_log     TYPE REF TO zcl_log.
"[...some code -  NOT touching lo_log] 
 " TODO: this is a NULL-reference!! (ABAP cleaner) 
	lo_log->add_message( ).
[... some more code]
CREATE OBJECT lo_log.
	lo_log->add_message( ).. 
"[...]
endmethod.

JoachimRees avatar Jun 19 '24 14:06 JoachimRees

Hi Joachim,

I completely agree: This is a bit more the domain of static code checks (i.e. the "check" ellipsis, not the "automate" ellipsis of ABAP Tools for Clean ABAP), but there is indeed an overlap – basically whenever ABAP cleaner generates a TODO comment – and since ABAP cleaner is probably run more frequently, why not help developers discover this immediately.

Meanwhile, ABAP code samples with ABAP cleaner TODO comments start to appear on the internet ;-)

Kind regards, Jörg-Michael

jmgrassau avatar Jun 26 '24 09:06 jmgrassau