You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
"Align parameters and components": Options do not behave as expected #81
Hi Jörg-Michael, the options of rule "Align parameters and components" don't behave as I would expect them to.
Problem 1
What exactly is the difference between A ("normal") and B ("for single-line parentheses)?
I would have expected this example to fit type B, but it actually is type A:
DATA long_structure_name TYPE bapiret2.
DATA(lv_long_result_name1) = example_method_call( long_structure_name-message ).
Problem 2
Could it be that the line length doesn't consider indentations at the start of the line?
Let's take the same example:
DATA long_structure_name TYPE bapiret2.
DATA(lv_long_result_name1) = example_method_call( long_structure_name-message ).
Notice that there are four spaces in the beginning. (This example is in a method of a local class of a program.)
The line is 84 characters long in total, but a maximum line setting of 83 does nothing. It only works when setting it to 80.
For my tests, I only experimented with the first two options. The other options remained the same:
changed the title [-]Align parameters and components: Options do not behave as expected[/-][+]"Align parameters and components": Options do not behave as expected[/+]on Jul 28, 2023
You could as well call this "tabular style". This could occur quite frequently in test code, and I think this tabular style is very nice to read. Therefore, by default, ABAP cleaner "grants" some extra line width for such cases (160 chars, as opposed to 120 chars for "normal" cases), thus trying to preserve tabular style, unless it significantly exceeds line length.
Regarding your second question: The indentation is considered, but the closing parentheses and the period are not. That's why the "tipping point" is 3 chars later than you would have expected it. The reason for this is that in a case like …
… the last row would otherwise have a severe "disadvantage", because it is followed by three closing parentheses. If this led to different alignment for the last row, it wouldn't look good.
That's why the line length setting isn't "exact science" here.
Kind regards,
Jörg-Michael
P.S.: At some point, I would also like to add an option (or even a cleanup rule) that creates tabular style in cases that are short enough. Currently, it is just preserved if it already exists in the code.
yes, that makes sense… do you think "tabular style" would be better than "single-line parentheses"? I guess so …
Usually, I also try to set up the default example in a way that shows the effect of each option, so changing an option should usually also have an effect on the default examples (and that probably explains things better than a text would).
Activity
[-]Align parameters and components: Options do not behave as expected[/-][+]"Align parameters and components": Options do not behave as expected[/+]jmgrassau commentedon Jul 28, 2023
Hi ConjuringCoffee,
type B ("for single-line parentheses") refers to table rows that contain multiple components, but still fit into one single code line, e.g.:
You could as well call this "tabular style". This could occur quite frequently in test code, and I think this tabular style is very nice to read. Therefore, by default, ABAP cleaner "grants" some extra line width for such cases (160 chars, as opposed to 120 chars for "normal" cases), thus trying to preserve tabular style, unless it significantly exceeds line length.
The alternative would be much harder to read:
Regarding your second question: The indentation is considered, but the closing parentheses and the period are not. That's why the "tipping point" is 3 chars later than you would have expected it. The reason for this is that in a case like …
… the last row would otherwise have a severe "disadvantage", because it is followed by three closing parentheses. If this led to different alignment for the last row, it wouldn't look good.
That's why the line length setting isn't "exact science" here.
Kind regards,
Jörg-Michael
P.S.: At some point, I would also like to add an option (or even a cleanup rule) that creates tabular style in cases that are short enough. Currently, it is just preserved if it already exists in the code.
ConjuringCoffee commentedon Jul 28, 2023
Thank you for the quick and thorough explanations! Do you think some of this could be better explained on the UI or somehwere in the documentation?
jmgrassau commentedon Jul 28, 2023
Hi ConjuringCoffee,
yes, that makes sense… do you think "tabular style" would be better than "single-line parentheses"? I guess so …
Usually, I also try to set up the default example in a way that shows the effect of each option, so changing an option should usually also have an effect on the default examples (and that probably explains things better than a text would).
Kind regards,
Jörg-Michael
jmgrassau commentedon Jul 31, 2023
Hi ConjuringCoffee,
I now renamed the option for "max. line length B" a bit …
… and added a comment in the examples, referring to the option:
Hope that helps to make "A" and "B" more understandable – along with the possibility to change the value and observe what happens to the example!
Kind regards,
Jörg-Michael
clarify options on line length A/B in AlignParametersRule example (SA…
clarify options on line length A/B in AlignParametersRule example (#81)
ConjuringCoffee commentedon Jul 31, 2023
Yes, I think this makes it much clearer. Thanks!