SAP/abap-cleaner

Delete unused variables

Closed this issue · 2 comments

Hey again,

sorry but today it is a strange day 😄

When I use the ABAP Cleaner, it doesn't delete the unused variables in some cases. I have set up an example. image image It moves the used variables, so it seems to recognize that the others are not used. If I remove the "ASSIGN" commands, it deletes everything.
Here is the entire profile again: profile.zip

Sorry for so much work today. But I love your tool!

Thanks.

Best regards, Joachim

Hi Joachim,

thanks for opening this! Unfortunately, this is "no defect", because as soon as ABAP cleaner finds a dynamic ASSIGN ('...') (or macro usage or test injection), it skips the "Delete unused variables" rule altogether for the current method. While things are obvious in your example, it would generally be too difficult (and in many cases, impossible) to determine which variables are used dynamically and which aren't.

But please keep going! Maybe you just have some pieces of rare syntax in today's code, which ABAP cleaner has never been confronted with!

Kind regards,
Jörg-Michael

P.S.: Other rules that may be skipped in such cases are "Use FINAL for immutable variables", "Remove needless CLEAR", and "Report unused parameters".

Hi Jörg-Michael,

thank you very much for your explanation. Now I can understand that.

Best regards,
Joachim