-
Notifications
You must be signed in to change notification settings - Fork 73
No blank lines in function headers #630
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
Conversation
This might be too strict. Noticed in cynkra/dm@155570b. With this PRstyler::style_text("c(\n a,\n\n b\n)")
#> c(
#> a,
#> b
#> ) Created on 2020-04-12 by the reprex package (v0.3.0) CRAN versionstyler::style_text("c(\n a,\n\n b\n)")
#> c(
#> a,
#>
#> b
#> ) Created on 2020-04-12 by the reprex package (v0.3.0) |
This behavior was introduced in #629. I think it’s exactly as intended. When and why would you prefer the blank line not to be removed? F you Walt to visually separate lines, you can put a comment on the blank line |
The empty line allows for better structuring of the code in my case, see cynkra/dm@155570b. I'm really looking for |
Adding an empty comment as a placeholder works but adds noise. Can we be more liberal with empty lines, e.g. only remove if |
It is only for styler::style_text(
"c(
1,
2
)
",
strict = FALSE
)
#> c(
#> 1,
#>
#> 2
#> ) Created on 2020-04-12 by the reprex package (v0.3.0) The change introduced with this PR concerns function headers: function(x,
y) {
# comment
} But I wonder if there are other ways to accommodate for your use case. Can you specify conditions under which you want to allow blank lines, e.g.
|
Indeed, missed that. I also like how the empty line is kept with styler::style_text('
f <- function(a = 1,
b = 2) {
here("we should keep", "that empty line above")
}', strict = FALSE)
#>
#> f <- function(a = 1,
#> b = 2) {
#>
#> here("we should keep", "that empty line above")
#> } Created on 2020-04-12 by the reprex package (v0.3.0) Maybe if there's a comment, we should keep all empty lines around that comment? |
yeah but empty lines after function header is another topic, let's discuss that in #371. Also, there is no intention to remove this empty line, rather in #371 we may even add one for longer function declarations.
Any insights on that from your side? While it is ok to defer to |
Maybe if there's a comment, we should keep all empty lines around that comment? |
You mean to preserve the blank lines in utils::globalVariables(c(
# pipe
".",
# nesting
"data",
...
)) for example? This sounds reasonable. Do you think there are cases when one has a blank line in his or her code and it's unintentional? Because if that does not hold, we should revert this PR. An alternative would be to extend the API and let
I think implementing this would require not so much effort and could be of great benefit for people who want to use |
I'd rather discuss If in doubt, user code is correct and should be kept unchanged, also with My huge |
Well the problem was I forgot to update one test in the other PR and then I rebased after merge but for some reason the commit was still part of this PR so sorry for the convolution. I think function headers are not a concern so much and after resolving #630 we can focus on function calls in #632. |
Closes #549.