Skip to content

Aligning single parameters for functional calls #66

Closed

Description

@jelliottp

I am using the "Align parameters and components" rule with the following settings:
image

Typically we are allowing one parameter behind functional calls since that would keep it on one line. This keeps it nice and tidy for exporting parameters, but the issue arises when IMPORTING or CHANGING is involved. The rule is then enforcing this type of format which I'd be surprised if anyone wanted:

class->method( CHANGING
                 field = value ).

I would like to see it still kept on the one line:

class->method( CHANGING field = value ).

Is there a way to accomplish this with the current settings? Or can it be tweaked to allow for this? I wouldn't want to uncheck "put keywords on own line", because then that negatively affects the scenarios where there are multiple parameters.

Activity

  1. jmgrassau commented on Jun 25, 2023

    @jmgrassau
    Member

    Hi Josh,

    good point – I completely agree that no-one would want …

    class->method( CHANGING
                     field1 = value1 ).

    That was easy to fix. However, what should be done if someone configures this:

    image
    image

    Should the rule then continue after the keywords as well (ignoring the second setting) …

    class->method( CHANGING field1 = value1
                            field2 = value2
                            field3 = value3 ).

    … or would you then rather expect …

    class->method( CHANGING
                     field1 = value1
                     field2 = value2
                     field3 = value3 ).

    … for cases that are not one-liners?

    Not sure here. We could of course turn the "…put keywords … on own line" into a selection, e.g. "Always / Only below the call / Never"; then the second option would 'allow' us to behave differently if we continue after the call.

    Kind regards,
    Jörg-Michael

  2. self-assigned this
    on Jun 25, 2023
  3. jmgrassau commented on Jun 26, 2023

    @jmgrassau
    Member

    Hi Josh,

    version 1.4.1 was just released and should do the trick for one-liners. Keeping this open, though, to find a solution for multi-line cases as well.

    Kind regards,
    Jörg-Michael

  4. jelliottp commented on Jun 27, 2023

    @jelliottp
    Author

    Thank you!

    Regarding the multi-line cases, we are not running into this since we're limiting to 1 parameter behind the call. However, if I was to use it for multiple lines and I had the "Put keywords on own line" setting on, I would assume I'd get this:

    class->method( CHANGING
                     field1 = value1
                     field2 = value2
                     field3 = value3 ).
    

    I would like to hear from others though who are using the settings in this manner.

  5. jmgrassau commented on Jul 5, 2023

    @jmgrassau
    Member

    Hi Josh,

    perfect, then the behavior for >1 parameter is as you would expect it, too. Unless someone explicitly wants >1 parameters cases to look different, we can close this for now!

    Kind regards,
    Jörg-Michael

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

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions