Remove extra spaces inside parentheses
This was initially mentioned in #20.
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?
Before
DATA(var) = VALUE #( ( field1 = value1 ) ).
After
DATA(var) = VALUE #( ( field1 = value1 ) ).
There was some discussion about possibly keeping some spaces in a tabular layout (I don't have much opinion on that since I don't have an example when I'd ever want to do that), but I think this could be applied in a straightforward way when there is only one field.
Hi Josh,
thanks for opening a dedicated issue for this! As mentioned in #20, my idea would be to create a new cleanup rule "Align components in tabular layout" (or similar), which would align cases such as …
DATA(var) = VALUE some_type( ( amount = '1.23' name = 'short' )
( amount = '123.4' name = 'longer' )
( amount = '1234.56' name = 'very long' ) ).
… into …
DATA(var) = VALUE some_type( ( amount = '1.23' name = 'short' )
( amount = '123.4' name = 'longer' )
( amount = '1234.56' name = 'very long' ) ).
… providing options on
- maximum allowed line length,
- whether to create such alignment from previous multi-line cases,
- whether to align decimal places (as done above),
- whether to align closing parentheses
- whether to put two spaces between a value and the next component name etc.
This would then also cover your example (even if the closing parenthesis would, admittedly, not be the focus of the rule). The options would also benefit cases with just one field if there are multiple rows, so you'd get:
DATA(var) = VALUE some_type( ( amount = '1.23' )
( amount = '123.4' )
( amount = '1234.56' ) ).
or alternatively:
DATA(var) = VALUE some_type( ( amount = '1.23' )
( amount = '123.4' )
( amount = '1234.56' ) ).
Kind regards, Jörg-Michael
@jmgrassau I was about to create an enhancement request (issue) when I saw your suggestion of component alignment in one line, e.g. doing this automatically:
I guess it would be better for follow-up to have a new request created for this request, because I found it only because it was out of curiosity.
May I create one if you don't mind?