abap-cleaner
abap-cleaner copied to clipboard
Feature request: Use newer expressions
There are a number of newer expressions that seem like a good fit for a rule to replace the old syntax, such as:
- [ ] 1. CORRESPONDING #( ) - refer to #266
- [ ] 2. String templates -
partially complete in 1.15.0
refer to #116 - [x] 3. line_exists( )
1.14.0
- [x] 4. lines( )
1.14.0
- [x] 5. condense()
1.15.0
- [x] 6. translate( )
1.0.0
- [ ] 7. concat_lines_of( )
- [ ] 8. shift_left( ) & shift_right( )
- [x] 9. to_upper( ) & to_lower( )
1.0.0
- [x] 10. line_index( )
1.14.0
- [ ] 11. REF #( )
Hi Josh,
great, that sounds very promising for multiple new cleanup rules! We'd have to check about limitations for automation in the individual cases, of course, but looking forward to this!
Kind regards, Jörg-Michael
Hi Josh,
just to keep you updated, I now implemented an important prerequisite to some of these ideas, namely
- some helper functions to determine which ABAP commands change relevant system fields (sy-subrc, sy-tabix, sy-index, sy-tfill, sy-tleng), and
- a "ProgramFlowAnalyzer" (extended by "SyFieldAnalyzer") to find out which subsequent commands read them, before another command changes them again.
This is needed, obviously, because these newer expressions don't change the system fields, and we must excluded unexpected cases from cleanup (e.g. when the system field is first stored in a variable and evaluated at a different point).
To be continued!
Kind regards, Jörg-Michael
P.S.: Points 6 and 7 are already implemented with the "Replace TRANSLATE with string functions" rule, but line_index( )
could be added to the list.
Hi Josh,
FYI, for point 10 "String templates", a dedicated issue #116 was opened, so discussion for this particular point could be continued there.
Kind regards, Jörg-Michael
Hi @jmgrassau, just circling back to this one. The tool has become very stable and useful! Do you think any of these would make it as a priority soon?
Hi Josh,
thanks for the reminder, and really sorry that (due to limited capacity) there was no progress here for such a long time!
Hm, if you could choose, which of those 10 open ideas would you find most useful to start with?
Kind regards, Jörg-Michael
I think CORRESPONDING #( )
is probably the most common one I see right now so I’d start there. I believe it would need to include the BASE
addition to be a safe conversion from MOVE-CORRESPONDING
. String templates in #116 is also important.
I’ll also try to re-order the rest based on priority, and others can give their input here as well.
Hi Josh,
okay, starting small with an upcoming cleanup rule that changes DESCRIBE TABLE itab LINES lin
into lin = lines( itab )
:
However, the examples show that this is not entirely trivial:
Kind regards, Jörg-Michael
Great! Looks good, and you are right there are some outliers to be aware of.
Hi Josh,
release 1.14.0 will also offer the new rule "Replace READ TABLE with table expression" (for 3. line_exists( ) and 10. line_index( ), and additionally for ASSIGN):
Examples:
However, unfortunately, the rule can't automate everything, which is also explained in the examples:
Kind regards, Jörg-Michael
P.S.: Is 6. translate( ) fulfilled with the rule "Replace TRANSLATE with string functions" or is anything missing there?
These are great additions, thank you!
Also, yes translate()
is already covered so I've checked that one off as well.
Hi Josh,
perfect, thanks once again for this inspiring list! (And nicely done with the ticks, references and version numbers!) Already doing some research on some of the other points …
Kind regards, Jörg-Michael
There's a dedicated issue for CORRESPONDING
now: https://github.com/SAP/abap-cleaner/issues/266
Hi Josh,
version 1.15.0, which was just released, now includes the new cleanup rules "Use string templates to assemble text" (for 2.) and "Replace CONDENSE with string function" (for 5.)!
Kind regards, Jörg-Michael