Open VladGhitulescu opened 3 months ago
I think first of all we have "Do not chain up-front declarations" and we should not encourage deviating from the recommendation by implementing what you proposed.
Secondly, I don't have a resource at hand, but I also think that it is recommended to declare your variables right before you use them, not at the very top in a very big block like in the example. "Prefer inline to up-front declarations" is related to that.
Hi Vlad,
I'm not sure whether an alphabetical order is really what you'd want? What ABAP cleaner currently offers is the rule "Rearrange local declarations", which sorts 1. by declaration keyword (TYPES, CONSTANTS, STATICS, DATA, FIELD-SYMBOLS) and 2. among the same keyword, "in order of appearance", so the local variable that is used first will be declared first. IMHO, this helps readability of long methods with many variables, because variables that are used in the same section of the method are then declared together. Looking at the configuration options, you can also move variables to the innermost blocks. It would be possible, of course, to add another option for alphabetical sorting here.
Kind regards, Jörg-Michael
P.S.: A true clean code advocate would of course tell you that there is never the need for more than 2-3 variables in a method. But judging from reality, I doubt that's true for ABAP…
Hey,
After updating Eclipse & Co. I've just discovered an useful update to ABAP Quick Fixes (version 1.1.5): "Sort combined DATA statement":
What do you think?
Regards, Vlad