abap-cleaner icon indicating copy to clipboard operation
abap-cleaner copied to clipboard

Method call parameters in lower case

Open D029515 opened this issue 10 months ago • 4 comments

Suggestion for a new rule: The parameters of method calls are sometimes in mixed case (because of copy and paste...) It would be nice to format them all in lower case.

Here's an example: Image

D029515 avatar Mar 04 '25 07:03 D029515

What are your settings for rule "Convert upper and lower case"? I think if you uncheck "Keep camel case identifiers", then it should behave as you want it to.

ConjuringCoffee avatar Mar 04 '25 11:03 ConjuringCoffee

Yes, you're right. I wasn't aware of the fact that this may be camel case as well. This solves my current request, but on the other hand it would destroy 'real' camel case coding, what is also not wanted. Currently I have no idea, how to distinguish...

D029515 avatar Mar 04 '25 11:03 D029515

If your "real" camel case coding is only in the context of CDS views, then you could set up the rules "Use CamelCase for known CDS names" with your own names. This requires some effort to maintain though.

ConjuringCoffee avatar Mar 04 '25 12:03 ConjuringCoffee

Hi Claudia,

I wonder if it would help – at least in some cases – if ABAP cleaner would align identifiers with their declaration? For example, with the following code, the rule "Convert upper and lower case" will only process all-upper and all-lower identifiers, but keep the mixed ones:

Image

Even with changing LV_VALUE to lv_value, the same local variable is still written in 3 different ways. So, another approach could be to align all usages of lv_Value to the way it is declared. The result would be:

  METHOD any_method.
    DATA lv_Value TYPE i.
    lv_Value = 1.
    lv_Value = 2.
    lv_Value = 3.
  ENDMETHOD.

This way, you would only need to care about the declaration, and all usages of the variable would follow.

That would come with the limitation, though, that ABAP cleaner cannot retrieve the declaration from the backend, so it is only known to ABAP cleaner if it is visible in the same code document. In your example, however, I guess there's a fair chance that the declaration of the current method (in which those iv_… parameters are declared) is found in the definition section of the same document. What do you think?

Kind regards, Jörg-Michael

P.S.: If you paste IV_GRP_ADMIN from the keyboard, adding an upper-case X would help, because an all-upper IV_GRP_ADMINX would be put to lower case by ABAP cleaner. It's only the mixed ones that are not touched if "Keep camel case identifiers" is active.

jmgrassau avatar Jul 01 '25 15:07 jmgrassau