SAP / abap-cleaner

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

Alignment of TYPES with TABLE and KEY specification #184

Open jfandy1982 opened 10 months ago

jfandy1982 commented 10 months ago

Hello,

I might have found an issue with formatting TYPES definitions. According to the interactive ABAPCleaner UI, the rule 'Align declarations' should be applied. I am using this rule with the default configuration settings of version 1.11.

It seems, that table definitions across several lines are the issue here. The TYPE keyword is aligned with the name of the defined table type. But the addition with the key specification for the table is not adjusted. The line length exceeds the default value.

Before:

interface zif_test_interface
  public .

  types ty_tt_table_name type sorted table of table_name
                           with unique key key1 key2.
  types ty_tt_loooooong_tabe_name type standard table of loooooong_tabe_name.

endinterface.

After:

interface zif_test_interface
  public.

  types ty_tt_table_name          type sorted table of table_name
                           with unique key key1 key2.
  types ty_tt_loooooong_tabe_name type standard table of loooooong_tabe_name.

endinterface.

Result Option 1: Pull it into the previous line, if configured line length allows.

interface zif_test_interface
  public.

  types ty_tt_table_name          type sorted table of table_name with unique key key1 key2.
  types ty_tt_loooooong_tabe_name type standard table of loooooong_tabe_name.

endinterface.

Result Option 2: Format is the same way as the constants example in the rule configuration screen.

interface zif_test_interface
  public.

  types ty_tt_table_name          type sorted table of table_name
                                  with unique key key1 key2.
  types ty_tt_loooooong_tabe_name type standard table of loooooong_tabe_name.

endinterface.

Would it be possible? Or are there other constraints, which contradict that? I don't prefer any option, but I like the consistency, the ABAPCleaner tool creates.

Kind regards, Andreas Ziegler

songzc3 commented 10 months ago

Add Option 3: 246869ed3a26de3f2e2198784156339b

jmgrassau commented 10 months ago

Hi Andreas,

you're right, the "Align declarations" rule so far only changes the first line of multi-line table type definitions (which could get rather complex if you define multiple secondary keys etc.). So, it would be a good enhancement to care for those following lines, too – at least by moving them along with the TYPE of the first line!

Kind regards, Jörg-Michael