-
Notifications
You must be signed in to change notification settings - Fork 72
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Introduce line-breaks in multiline arguments #1244
base: main
Are you sure you want to change the base?
Conversation
…b/styler into f209-newline-multiline-args
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
Wow, that's quite the slowdown. Need to figure out what's causing it once the scope is clear. |
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
@lorenzwalthert Any thoughts? I am blocked here without any further feedback from the team. |
Maybe we should talk about the abstract rule first. What is it exactly that we try to achieve? Also important: in the example you gave, all line breaks should simply be removed if we had #247. |
This is where I need some clarity. I am interpreting the discussion in tidyverse/style#209 to mean that the style guide recommends "one line per argument" rule. Elsewhere, the style guide carves out an exception to put multiple arguments per line, but the intent of clubbing similar arguments is not something Therefore, I opted to just always follow the stated rule and if users wish to retain multiple arguments per like, they will just have to add ignore directives. |
This comment was marked as outdated.
This comment was marked as outdated.
as it is evident from the test cases, enforcing one argument per line is quite a change to the current behaviour I'd discourage this, at least at this point. Also, sometimes you want more than one argument per line when named arguments are involved:
So I suggest to just focus on a small interesting scope first and then maybe extend it gradually. And in my view, a small improvement involves the focus of multi-line arguments and it is to enforce a line-break between two multi-line arguments using the c(
c(
'b'
), fun(
f = 2
)
)
# becomes
c(
c(
'b'
),
fun(
f = 2
)
)
Or even slightly more rigid, each multi-line expression has to be on its own line: c(
a, c(
'b'
), fun(
f = 2
)
)
# becomes
c(
a,
c(
'b'
),
fun(
f = 2
)
)
Comments should probably be ignored in that logic, i.e. token after or before comma should be defined as in skip the comments. Do you want to adapt your PR to that effect? I can also tell you how I'd solve the puzzle in abstract terms first, but I don't want to take away the fun of figuring it out, so you can go ahead if you want. |
This is how benchmark results would change (along with a 95% confidence interval in relative change) if 7525889 is merged into main:
Further explanation regarding interpretation and methodology can be found in the documentation. |
This is how benchmark results would change (along with a 95% confidence interval in relative change) if c624bfc is merged into main:
Further explanation regarding interpretation and methodology can be found in the documentation. |
cf. tidyverse/style#209
Created on 2024-12-20 with reprex v2.1.1