Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

AdT Code formater to help towards cleanABAP (empty lines, and other line-wasting) ?

joachimrees1
Active Contributor
2,073

Is there an AdT-code formater (linter?) that goes beyond what shift+f1 does?!

What I would want it do do is stuff like this (which I as of now do by hand):

- If more than 1 empty line: replace those with exactly 1 empty line.

- Don't wast space in method definitions (this is how quick assists generates it)

*    METHODS do_something_xy
*      IMPORTING
*        iv_param TYPE abap_bool.
    METHODS do_something_xy IMPORTING iv_param TYPE abap_bool.

- don't waste a full line with only . and/or )

*    lref_report->do_something_xy( iv_param = abap_true
*                        ).
    lref_report->do_something_xy( iv_param = abap_true ).
1 ACCEPTED SOLUTION

joachimrees1
Active Contributor
1,255

Well, I think what I asked for is here now with ABAP Cleaner: https://github.com/SAP/abap-cleaner

16 REPLIES 16

joachimrees1
Active Contributor
0 Kudos
1,255

abaplint seems to be a solution, but as I unterstand it builds on abapGit and (maybe sad, but true) I have not yet added that to my developers toobox).

FredericGirod
Active Contributor
1,255

Hi Joachim,

I never seen something like that. But it could be interesting to be able to customize the layout.

Fred

S0025923934
Participant
1,255

I think this add-on can provide what you are asking for...

ABAP Quick Fix Functions so far:

  • Remove all comments (do not delete pseudo comments and ADT comments)
  • Remove all comments in selection (do not delete pseudo comments and ADT comments)
  • Replace icon literals with constant
  • Translate comments into English
  • Replace READ TABLE with ASSIGN
  • Replace READ TABLE with REF #( )
  • Reaplace READ TABLE with Table Expression
  • Replace CALL METHOD with direct call
  • Reaplace MOVE with direct assignment
  • Combine statements: DATA, TYPES, CONSTANTS, FIELD-SYMBOLS, CHECK, CLEAR, REFRESH, FREE, PARAMETERS, SELECT-OPTIONS, METHODS, CLASS-METHODS
  • Change APPEND TO to APPEND VALUE #( ) TO
  • Change INSERT INTO to INSERT VALUE #( ) INTO
  • Split combined(chained) statements
  • Remove Line Break at end of statement
  • Replace CREATE OBJECT with NEW
  • Omit EXPORTING in method call
  • Omit RECEIVING in method call
  • Change APPEND TO to INSERT VALUE #( ) INTO
  • Replace GET REFERENCE with REF #
  • Replace READ TABLE TRANSPORTING NO FIELDS with LINE_EXISTS
  • Remove full line comments from statement
  • Omit self reference ME->
  • Replace operators EQ,NE,GT,GE,LT,LE with =,<>,>,>=,<,<=
  • Align operators (in selected cod

1,255

I have that AddOn installed, and I didn't think it does what I want, but I looked at it again and tried it and it seems to help quite a bit:

Those are the QuickAssists that help me in those case

  • Remove Line Break at end of statement
  • Combine statements METHODS

Thanks!

ThFiedler
Product and Topic Expert
Product and Topic Expert
1,255

Hi Joachim,

We have a tool in the pipeline to clean up ABAP code based on the clean code rules. SAP internal tests are already running. I will keep you posted.

Regards, Thomas

abo
Active Contributor
1,255

Ooooooohhhhhhh 🙂

0 Kudos
1,255

Oh, that's very nice to hear, thomasfiedler ! I'm looking forward to it, thanks a lot!

Joachim

0 Kudos
1,255

Any news or a timeline for that, yet thomasfiedler ?

I am still very interested in that feature!

ThFiedler
Product and Topic Expert
Product and Topic Expert
1,255

First steps are done towards an Open Source project. Let's see when it goes live.

Regards,

Thomas.

1,255

Thanks a good news 🙂

0 Kudos
1,255

> "First steps are done towards an Open Source project"

sounds nice, but does this mean it will not be part of the SAP / AdT standard ?! 😞

I would hope for it to just work, once I am on a certain Backend+AdT-Release....

thomasfiedler

ThFiedler
Product and Topic Expert
Product and Topic Expert
1,255

The tool is planned to be eclipse-only and works without any dependencies to the ABAP backend.

But as this will be an Open source tool it will not be part of the standard ADT installation. The same apporach as for the Code-PAL ATC Checks.

Regards,

Thomas.

0 Kudos
1,255

ok, got that.

So: any news on the arrival yet?

0 Kudos
1,255

Just for the record: ABAP Cleaner is what I wanted. And it's here now. Awesome!
https://github.com/SAP/abap-cleaner

joachimrees1
Active Contributor
1,256

Well, I think what I asked for is here now with ABAP Cleaner: https://github.com/SAP/abap-cleaner