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
Similar to existing space rules, there should be rule (or perhaps include in "Close brackets at line end"?), where a space is expected between a ' and ( or ) for method calls and inside VALUE statements.
well, in the end I thought that there was always some lack of complexity to the cleanup rule "Remove multiple spaces in empty parentheses" :-), so in the next release, that rule will be renamed to "Standardize spaces next to parentheses" and enhanced as follows:
Activating the third option will additionally change lines 8, 22-24, and 32:
Hope that works. As lines 27-29 show, some care was needed to not mess up cases with dynamic (method, component, attribute, …) names.
I have a couple other cases we've run into with standardization of spaces. I'm not sure if these still fit in this rule or not.
Within IF/ELSEIF statements, we should remove extra spaces (this may apply to other statements, I haven't verified yet):
Before
IF line_exists( some_table[ field = value ] ).
ENDIF.
After
IF line_exists( some_table[ field = value ] ).
ENDIF.
Within parentheses, there is a rule to remove extra spaces for empty parentheses, but the problem exists when there are parameters as well. Perhaps these should both be handled and rename the rule to Removes multiple spaces from inside parentheses?
the new options "Separate parentheses from character literals" and "Separate condensed cases …" are now available in version 1.3.0!
Regarding your last comment, the extra space in example 1. seems to be handled by the "Align logical expressions" rule already:
Regarding point 2, however, I think this would be worth opening a new issue, and I guess it would be for a new cleanup rule "Align components in tabular layout" (or similar). Actually this has been on my wish list for a long time already (this being a frequent case in our unit tests). Consider the following example:
I think this was carefully aligned, and the author probably wouldn't want ABAP cleaner to mess with such an alignment by removing the spaces after "amount =" or before the closing ")". Rather, they may want ABAP cleaner to create this tabular layout where possible (with lots of configuration options, of course :-), maybe even from multi-line scenarios, if the components fit into the allowed line width.
This could get a little complex, however, if not all rows have the same selection of components, if there are comments in between etc.. So – good point, but probably a larger endeavor to find a good solution!
Regarding point 1, we am not using the "Align logical expressions" rule currently, so this doesn't get handled. This is because it comes with a lot of extra alignment that isn't desired (purposely adding spaces in front of IF/WHILE/CHECK statements feels like an anti-pattern to me, but I understand if others want it).
I feel that rule is meant to handle IF statements with multiple conditions, but here I'm just trying to condense a statement with one condition. Is there some way to accommodate this situation?
Activity
jmgrassau commentedon May 24, 2023
Hi Josh,
oh, that's an excellent idea, will do! I never understood why ABAP syntax even allows this…
Kind regards,
Jörg-Michael
jmgrassau commentedon May 24, 2023
P.S.: Hm, it doesn't really fit into any of the existing rules, so I think a dedicated rule would make sense.
jelliottp commentedon May 24, 2023
I agree, it should be a syntax error. Also, I edited above, the same issue applies to
(and'.ConjuringCoffee commentedon May 25, 2023
Please note that it also applies to the backtick
`and not just'.jmgrassau commentedon May 30, 2023
Hi Josh and @ConjuringCoffee,
well, in the end I thought that there was always some lack of complexity to the cleanup rule "Remove multiple spaces in empty parentheses" :-), so in the next release, that rule will be renamed to "Standardize spaces next to parentheses" and enhanced as follows:
Activating the third option will additionally change lines 8, 22-24, and 32:
Hope that works. As lines 27-29 show, some care was needed to not mess up cases with dynamic (method, component, attribute, …) names.
Kind regards,
Jörg-Michael
jmgrassau commentedon May 30, 2023
P.S.: Hm, the wording is a bit difficult, maybe it's better like this:
jelliottp commentedon May 31, 2023
This looks great! Thanks for working on this.
jelliottp commentedon May 31, 2023
I have a couple other cases we've run into with standardization of spaces. I'm not sure if these still fit in this rule or not.
IF/ELSEIFstatements, we should remove extra spaces (this may apply to other statements, I haven't verified yet):Before
After
Removes multiple spaces from inside parentheses?Before
After
add options to 'Add space between parentheses and char. literals' (SA…
add options to 'Add space between parentheses and char. literals' (#20)
jmgrassau commentedon Jun 6, 2023
Hi Josh,
the new options "Separate parentheses from character literals" and "Separate condensed cases …" are now available in version 1.3.0!
Regarding your last comment, the extra space in example 1. seems to be handled by the "Align logical expressions" rule already:
Regarding point 2, however, I think this would be worth opening a new issue, and I guess it would be for a new cleanup rule "Align components in tabular layout" (or similar). Actually this has been on my wish list for a long time already (this being a frequent case in our unit tests). Consider the following example:
I think this was carefully aligned, and the author probably wouldn't want ABAP cleaner to mess with such an alignment by removing the spaces after "amount =" or before the closing ")". Rather, they may want ABAP cleaner to create this tabular layout where possible (with lots of configuration options, of course :-), maybe even from multi-line scenarios, if the components fit into the allowed line width.
This could get a little complex, however, if not all rows have the same selection of components, if there are comments in between etc.. So – good point, but probably a larger endeavor to find a good solution!
Kind regards,
Jörg-Michael
jelliottp commentedon Jun 22, 2023
Hi @jmgrassau, I created #67 for my point 2 above.
Regarding point 1, we am not using the "Align logical expressions" rule currently, so this doesn't get handled. This is because it comes with a lot of extra alignment that isn't desired (purposely adding spaces in front of IF/WHILE/CHECK statements feels like an anti-pattern to me, but I understand if others want it).
I feel that rule is meant to handle IF statements with multiple conditions, but here I'm just trying to condense a statement with one condition. Is there some way to accommodate this situation?