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

"Remove needless parentheses" overshadows "align logical expressions" in list of rules used

Open ConjuringCoffee opened this issue 2 years ago • 2 comments

Hi Jörg-Michael, thanks for adding support for SELECT statements! While I was testing, I noticed something fishy going on with the display of the "rules used in current selection".

Example:

SELECT *
  FROM mara
  INTO TABLE @DATA(lt_mara)
  WHERE     ( matnr = 'A'        OR matnr = 'B' )
        AND ( lvorm = 'A' ).

Notice the extra spaces before the OR. They are removed by the ABAP Cleaner, but only one rule is shown as used:

image

image

If I remove the parenthesis beforehand, another rule surfaces:

image

image

Shouldn't both rules be displayed for the first example?

ConjuringCoffee avatar Nov 27 '23 12:11 ConjuringCoffee

Hi ConjuringCoffee,

hm, yes, you're right. Technically, the reason is this:

image

So you get the execution of two rules for the price of one :-) Showing both rules in the "Rules Used" list would only make sense if you could then also (locally) deactivate "Align logical expressions" for the current selection in the diff view – I shall give that a try!

Kind regards, Jörg-Michael

P.S.: There are a few other examples where rules run have to other rules, particularly if the 'other rule' is earlier in the execution sequence (ABAP cleaner always runs the rules from top to bottom, meaning that it first runs "Standardize empty lines within methods" on the whole code, then "Separate methods and classes with empty lines" on the whole code etc.)

jmgrassau avatar Nov 28 '23 09:11 jmgrassau

Ah, I didn't see that! That makes more sense. Knowing that, I would be fine if the behavior stays as-is.

ConjuringCoffee avatar Nov 28 '23 09:11 ConjuringCoffee