Skip to content

feature request: styling function definition with multiple arguments to one argument per line #719

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

Closed
IndrajeetPatil opened this issue Jan 28, 2021 · 1 comment

Comments

@IndrajeetPatil
Copy link
Collaborator

The tidyverse style guide mentions:

image

Although it doesn't explicitly recommend that when the function definition looks like the following, there should be one argument per line to improve readability, but I am guessing that this is something implicitly being hinted at? Not sure.

styler::style_text(
'
foo <- function(posteriors, centrality = "median", dispersion = FALSE, ci = 0.89, ci_method = "hdi", test = c("p_direction", "rope"), rope_range = "default", rope_ci = 0.89, component = c("all", "conditional", "location"), parameters = NULL, ...) {}
'
)
#> 
#> foo <- function(posteriors, centrality = "median", dispersion = FALSE, ci = 0.89, ci_method = "hdi", test = c("p_direction", "rope"), rope_range = "default", rope_ci = 0.89, component = c("all", "conditional", "location"), parameters = NULL, ...) {}

Nevertheless, I was wondering if you think this (styling to one argument per line) is something that styler should be doing by default? Of course, it might not make sense to do this when there are only a few (3-4?) arguments present, but would have increasing utility the more arguments are present.

@lorenzwalthert
Copy link
Collaborator

Thanks. I don't think function declarations should be treated differently in this regard than other code.That is, it should be broken at 80 characters. We have #247, which I think should cover this case, however, as mentioned in #247 (comment), we'll probably start with function calls since they are the vast majority offending cases, and then maybe come back to the declaration case.

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

2 participants