Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove extra spaces inside parentheses #67

Open
jelliottp opened this issue Jun 22, 2023 · 2 comments
Open

Remove extra spaces inside parentheses #67

jelliottp opened this issue Jun 22, 2023 · 2 comments

Comments

@jelliottp
Copy link

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.

@jmgrassau
Copy link
Member

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

@sandraros
Copy link

@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:

image

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants