Skip to content

Commit 36cd6ea

Browse files
allow no line break after ( for function calls
With strict = FALSE, lines are not broken.
1 parent 39773c3 commit 36cd6ea

8 files changed

+261
-5
lines changed

R/style_guides.R

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,14 +95,14 @@ tidyverse_style <- function(scope = "tokens",
9595
add_line_break_afer_curly_opening,
9696
if (strict) set_line_break_before_curly_closing else
9797
add_line_break_before_curly_closing,
98-
partial(
98+
if (strict) partial(
9999
set_line_break_after_opening_if_call_is_multi_line,
100100
except_token_after = "COMMENT",
101101
except_text_before = c("switch", "ifelse", "if_else")
102-
),
103-
partial(
102+
) else identity,
103+
if (strict) partial(
104104
set_line_break_before_closing_call, except_token_before = "COMMENT"
105-
),
105+
) else identity,
106106
remove_line_break_in_empty_fun_call,
107107
add_line_break_after_pipe
108108
)
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
call(call(
2+
2
3+
))
4+
5+
call(call(1,
6+
2))
7+
# multi-line: no indention based on first vall
8+
call(a(b(c({
9+
}))))
10+
11+
call(call(
12+
2 ) ,
13+
5 )
14+
15+
16+
call(call(1,
17+
2, c(
18+
3
19+
)))
20+
21+
call(1,
22+
call2(3, 4, call(3,
23+
4, call(5, 6, call(
24+
2
25+
)
26+
)
27+
)
28+
)
29+
)
30+
31+
# comment lala
32+
33+
call(call(
34+
2
35+
))
36+
37+
call(1, call(
38+
23
39+
))

tests/testthat/line_breaks_fun_call/token_dependent_complex_non_strict-in_tree

Lines changed: 166 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
call(call(
2+
2
3+
))
4+
5+
call(call(
6+
1,
7+
2
8+
))
9+
# multi-line: no indention based on first vall
10+
call(a(b(c({
11+
}))))
12+
13+
call(
14+
call(
15+
2
16+
),
17+
5
18+
)
19+
20+
21+
call(call(
22+
1,
23+
2, c(
24+
3
25+
)
26+
))
27+
28+
call(
29+
1,
30+
call2(3, 4, call(
31+
3,
32+
4, call(5, 6, call(
33+
2
34+
))
35+
))
36+
)
37+
38+
# comment lala
39+
40+
call(call(
41+
2
42+
))
43+
44+
call(1, call(
45+
23
46+
))

tests/testthat/test-line_breaks_fun_call.R

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,14 @@ test_that("line breaks work in general", {
66

77
expect_warning(test_collection("line_breaks_fun_call",
88
"token_dependent_complex",
9-
transformer = style_text), NA)
9+
transformer = style_text, strict = FALSE), NA)
1010
})
1111

12+
test_that("line breaks are not applied with non-strict", {
13+
expect_warning(test_collection("line_breaks_fun_call",
14+
"token_dependent_complex",
15+
transformer = style_text), NA)
16+
})
1217

1318
test_that("line breaks work with comments", {
1419
expect_warning(test_collection("line_breaks_fun_call",

0 commit comments

Comments
 (0)