Description
I think we've hewed too closely to the style guide after #714:
library(styler)
styler::style_text('
switch(
x,
a = 1,
b = 2,
c = 3
)')
# switch(x,
# a = 1,
# b = 2,
# c = 3
# )
Understand the switch()
example in the style guide is like that, but I think both having x
on its own line and moving it to switch(x
are acceptable per the overall style guide, so styler
shouldn't override valid syntax.
My reasoning is per: https://style.tidyverse.org/syntax.html#long-lines
As described under Named arguments, you can omit the argument names for very common arguments (i.e. for arguments that are used in almost every invocation of the function). Short unnamed arguments can also go on the same line as the function name, even if the whole function call spans multiple lines.
This becomes worse when the first argument is an expression, not just a symbol:
library(styler)
styler::style_text('
switch(
tolower(x$switch_column),
a = 1,
b = 2,
c = 3
)')
# switch(tolower(x$switch_column),
# a = 1,
# b = 2,
# c = 3
# )
Here I think the original version is much clearer.