SAP / abap-cleaner

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

Syntax Error caused by rule "Simplify a chain with one element" inside Includes #372

Closed openPhiL closed 2 weeks ago

openPhiL commented 4 weeks ago

Hello Jörg-Michael, The following scenario is leading to a wrong cleaning: Rule: "Simplify a chain with one element" with the default options

When we apply the cleaner to this code:

DATA:
  "! Only used for declaring select-option
  gv_serial_number TYPE gernr.

it will produce this code:

"! Only used for declaring select-option DATA gv_serial_number TYPE gernr.

Important: This seems to only happen because the object that we found is an include where the DATA:-line is literally the first line of the object. Any other command or even comment above the DATA will prevent this error.

Thank you for looking into it! PhiL

jmgrassau commented 2 weeks ago

Hi PhiL,

ooops … Nice finding! Internally, ABAP cleaner always stores the number of line breaks above (and spaces left of) each token. At document start this can be 0, and this special case case was obviously not considered here. Will be fixed with the next release!

image

Kind regards, Jörg-Michael

jmgrassau commented 2 weeks ago

Hi openPhiL,

thanks for this bug reporting – this shouldn't come up again with version 1.20.1!

Kind regards, Jörg-Michael