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

Rule "Remove space before commas and period" duplicates template comment in function module #348

Closed ConjuringCoffee closed 2 months ago

ConjuringCoffee commented 3 months ago

Hi Jörg-Michael, the rule "Remove space before commas and period" causes a problem in function modules without parameters.

Example:

FUNCTION z_test.
  WRITE 'hello world'.
ENDFUNCTION.

When this function module is saved, a comment is automatically added by SAP standard:

FUNCTION Z_TEST
 " You can use the template 'functionModuleParameter' to add here the signature!
.

  WRITE 'hello world'.
ENDFUNCTION.

Ignoring the infuriating grammar issue in the comment, this is how it looks like after the ABAP Cleaner is executed:

FUNCTION z_test.
  " You can use the template 'functionModuleParameter' to add here the signature!

  WRITE 'hello world'.
ENDFUNCTION.

When saving again, the comment is added once again:

FUNCTION Z_TEST
 " You can use the template 'functionModuleParameter' to add here the signature!
.

  " You can use the template 'functionModuleParameter' to add here the signature!

  WRITE 'hello world'.
ENDFUNCTION.

This can be repeated indefinitely.

These are the options I used: image

jmgrassau commented 3 months ago

Hi ConjuringCoffee,

very nice finding indeed! (And yes, the grammar in this auto-generated comment is painful!)

Kind regards, Jörg-Michael

jmgrassau commented 2 months ago

Hi ConjuringCoffee,

I could reproduce this issue on Aug. 22nd, but it seems to me that in the meantime, this comment is not generated anymore when the function module is saved! Nevertheless, I changed the cleanup rule to skip this exact case:

image

Kind regards, Jörg-Michael

ConjuringCoffee commented 2 months ago

Thanks!

I'm on the latest ADT version and the comment is still being generated for me. Maybe your ADT / your backend system is even more up-to-date 😉

jmgrassau commented 2 months ago

Hi ConjuringCoffee,

thanks again for reporting this issue – this should now be fixed in version 1.19.3, which was just released!

And yes, maybe I did have an insight into some future ADT version here, who knows ;-)

Kind regards, Jörg-Michael

ConjuringCoffee commented 2 months ago

Great, thanks :)