Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perhaps interesting for ABAP Cleaner too: Sort combined DATA statements (ABAP Quick Fixes 1.1.5)? #346

Open
VladGhitulescu opened this issue Jul 30, 2024 · 2 comments

Comments

@VladGhitulescu
Copy link

Hey,

After updating Eclipse & Co. I've just discovered an useful update to ABAP Quick Fixes (version 1.1.5): "Sort combined DATA statement":

CleanShot 2024-07-30 at 13 52 00

CleanShot 2024-07-30 at 13 52 02

CleanShot 2024-07-30 at 13 52 03

What do you think?

Regards,
Vlad

@ghost
Copy link

ghost commented Oct 1, 2024

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.

@jmgrassau
Copy link
Member

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…

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants