SAP / abap-cleaner

ABAP cleaner applies 95+ cleanup rules to ABAP code at a single keystroke
Apache License 2.0
439 stars 48 forks source link

Chain / group multiple DATA/METHODS/CONSTANTS declarations #148

Open robinbaeurle opened 1 year ago

robinbaeurle commented 1 year ago

I just checked the available rules, but could not find a rule that groups consecutive declarations into one.

For example, when I have this code:

DATA one   type string.
DATA two   type string.
DATA three type string.

I would want the cleaner to group these consecutive declarations into one single declaration, like so:

DATA: one   type string,
      two   type string,
      three type string

This should work for:

Most important for my use case would be DATA and METHODS, the others would just be nice to have.

Is it possible to add such a rule?

jelliottp commented 1 year ago

Might I ask why you would want to do this? It is actually the opposite of what is recommended in the clean ABAP style guide, which abap-cleaner is meant to follow.

jmgrassau commented 1 year ago

Hi robinbaeurle,

yes, I remember a similar request in the Inner-Source phase of ABAP cleaner. It would certainly be technically possible, but as Josh pointed out, is it desirable (explicitly going against the style guide)? Maybe let's set this to "discussion wanted"!

Kind regards, Jörg-Michael

P.S.: In our team, people did like these declaration chains, because PrettyPrinter was able to align TYPEs inside them. But that's not an argument with ABAP cleaner anymore :-)

ConjuringCoffee commented 1 year ago

P.S.: In our team, people did like these declaration chains, because PrettyPrinter was able to align TYPEs inside them. But that's not an argument with ABAP cleaner anymore :-)

Hmm, but doesn't indenting unchained statements go against the style guide as well? Specifically "Don't align type clauses". Indenting unchained statements is also introducing a lot of whitespace changes whenever a variable is changed. The way I see it, the default profile's setting for "Action for consecutive non-chains" in rule "Align declarations" goes against the style guide.

PS: I'm not sure where my personal stance on this topic is 😅