You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Maybe. I liked it that way more though, it's more compact. Is there a rule in the tidyverse style guide that discourages this use? Note that with strict = FALSE, the output is not as desired, i.e. there should be indention for the braces:
So then if you prefer another behavior, I suggest to propose/formalize a rule in tidyverse/style first :-). In the meantime, we nevertheless need to fix the brace indention with strict = FALSE, so I opened #430.
Created on 2018-10-01 by the reprex package (v0.2.1.9000)
The style guide seems to prefer brevity over comprehensiveness. If we want a comprehensive style guide, we could add an appendix where all the rules are formalized. Or we just use common sense and agreement :-o
text<-'library(dplyr, warn.conflicts = FALSE)tibble(x = 1) %>% mutate(y = { x <- 2; x }, z = x)'styler::style_text(text)
#> #> library(dplyr, warn.conflicts = FALSE)#> tibble(x = 1) %>%#> mutate(y = {#> x <- 2#> x#> }, z = x)
Created on 2018-10-04 by the reprex package (v0.2.1.9000)
I think that function arguments that consist of a braced expression always need to start on a new line, unless it's the last argument and all other arguments fit on the line of the function call:
Working on that Shiny code now, letting styler have its way even if I don't like the formatting because I'm tired of undoing... (And we called it "non-invasive" ;-) )
Note that we pretty much had this discussion before: #125. Also, removing the rule remove_line_break_before_curly_opening() at first glance seems to result in the behavior you desire. However, the problem is that with that, we can't get a typical edge case right:
test_that("xyz", {
call()
})
I.e. in the above case, we'd move the opening { to the next line too. I think originally, for this reason, I decided to go for the more compact representation because it was simpler to implement.
Because we'd need to set line break based on multi-line attribute, which is not easily possible currently, as outlined in #357.
I think this is the rule that makes sense once #357 is resolve from above:
function arguments that consist of a braced expression always need to start on a new line, unless it's the last argument and all other arguments fit on the line of the function call.
Plus when they are named, they should start on the same line as the key and EQ_SUB:
It seems as we don't need #357 anyways because the line break is added in the same nest as the check for multi-line (via column lag_newlines) happens in other places. I opened #543.
Activity
lorenzwalthert commentedon Sep 28, 2018
Maybe. I liked it that way more though, it's more compact. Is there a rule in the tidyverse style guide that discourages this use? Note that with
strict = FALSE, the output is not as desired, i.e. there should be indention for the braces:Created on 2018-09-28 by the reprex package (v0.2.1)
krlmlr commentedon Sep 29, 2018
It's more compact, but it's much less readable, because it's very easy to overlook the
}, {. And when you find it, you wonder what the meaning is.I'm not aware of any specific rule.
lorenzwalthert commentedon Sep 30, 2018
So then if you prefer another behavior, I suggest to propose/formalize a rule in tidyverse/style first :-). In the meantime, we nevertheless need to fix the brace indention with
strict = FALSE, so I opened #430.krlmlr commentedon Oct 1, 2018
We only have a contradicting rule in 2.4:
The two braces are not related, one could argue that they shouldn't be on the same line by negation.
If we add additional arguments, indentation starts looking really weird, although no rule seems to specify this either:
Created on 2018-10-01 by the reprex package (v0.2.1.9000)
The style guide seems to prefer brevity over comprehensiveness. If we want a comprehensive style guide, we could add an appendix where all the rules are formalized. Or we just use common sense and agreement :-o
krlmlr commentedon Oct 4, 2018
Also interesting:
Created on 2018-10-04 by the reprex package (v0.2.1.9000)
I think that function arguments that consist of a braced expression always need to start on a new line, unless it's the last argument and all other arguments fit on the line of the function call:
tryCatch( { }, error = function(e) { } ) with_envvar(c(ENV = "var"), { }) test_that("test", { })krlmlr commentedon Oct 14, 2018
Working on that Shiny code now, letting styler have its way even if I don't like the formatting because I'm tired of undoing... (And we called it "non-invasive" ;-) )
Any chance we can achieve consensus here?
lorenzwalthert commentedon Oct 14, 2018
Note that we pretty much had this discussion before: #125. Also, removing the rule
remove_line_break_before_curly_opening()at first glance seems to result in the behavior you desire. However, the problem is that with that, we can't get a typical edge case right:test_that("xyz", { call() })I.e. in the above case, we'd move the opening
{to the next line too. I think originally, for this reason, I decided to go for the more compact representation because it was simpler to implement.Because we'd need to set line break based on multi-line attribute, which is not easily possible currently, as outlined in #357.
lorenzwalthert commentedon Mar 15, 2019
I think this is the rule that makes sense once #357 is resolve from above:
Plus when they are named, they should start on the same line as the key and
EQ_SUB:lorenzwalthert commentedon Sep 17, 2019
It seems as we don't need #357 anyways because the line break is added in the same nest as the check for multi-line (via column
lag_newlines) happens in other places. I opened #543.