Skip to content

Commit 2f1cc9b

Browse files
Merge pull request #1239 from r-lib/rm-line-breaks-between-funs
2 parents 73fd5a6 + 6b5a4c5 commit 2f1cc9b

29 files changed

+245
-15
lines changed

.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
# All available hooks: https://pre-commit.com/hooks.html
22
# R specific hooks: https://github.com/lorenzwalthert/precommit
3-
default_stages: [commit]
3+
default_stages: [pre-commit]
44
default_language_version:
55
python: python3
66

77
repos:
88
- repo: https://github.com/lorenzwalthert/precommit
9-
rev: v0.4.2
9+
rev: v0.4.3.9003
1010
hooks:
1111
- id: style-files
1212
args:

R/rules-line-breaks.R

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -447,3 +447,9 @@ remove_empty_lines_after_opening_and_before_closing_braces <- function(pd) {
447447

448448
pd
449449
}
450+
451+
452+
set_line_breaks_between_top_level_exprs <- function(pd, allowed_blank_lines = 2L) {
453+
pd$lag_newlines <- pmin(pd$lag_newlines, allowed_blank_lines + 1L)
454+
pd
455+
}

R/style-guides.R

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,8 @@ tidyverse_style <- function(scope = "tokens",
139139
if (strict) remove_line_break_before_round_closing_after_curly,
140140
remove_line_breaks_in_fun_dec =
141141
if (strict) remove_line_breaks_in_fun_dec,
142+
set_line_breaks_between_top_level_exprs =
143+
if (strict) set_line_breaks_between_top_level_exprs,
142144
style_line_break_around_curly = partial(
143145
style_line_break_around_curly,
144146
strict

tests/testthat/alignment/named-out.R

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,6 @@ call(
102102
)
103103

104104

105-
106105
# if all col1 arguments are named, col1 must also be aligned
107106
# not aligned
108107
fell(

tests/testthat/indention_curly_brackets/custom-out.R

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ if (value > 0) {
44
}
55

66

7-
87
if (value > 0) {
98
print(value)
109
}

tests/testthat/line_breaks_and_other/assignment-out.R

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ x <-
2222
3
2323

2424

25-
2625
ImportantDataFrame$ImportantColumn1 <-
2726
ImportantDataFrame$ImportantColumn2 <-
2827
ComplicatedFunction(ImportantDataFrame$InputColumn)
@@ -32,6 +31,5 @@ ImportantDataFrame$ImportantColumn1 <-
3231
ImportantDataFrame$ImportantColumn2 <- ComplicatedFunction(ImportantDataFrame$InputColumn)
3332

3433

35-
3634
ImportantDataFrame$ImportantColumn1 <-
3735
ImportantDataFrame$ImportantColumn2 <- ComplicatedFunction(ImportantDataFrame$InputColumn)

tests/testthat/line_breaks_and_other/ggplot2-in.R

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ ggplot(data = mtcars, mapping = aes(x = mpg, y = vs)) +
2626
ggplot(data = mtcars, mapping = aes(x = mpg, y = vs)) + ggplot2::geom_point() + g() # comment
2727

2828

29+
2930
# add when comment
3031
ggplot(data = mtcars, mapping = aes(x = mpg, y = vs)) +
3132
ggplot2::geom_point() + g() + geom_oint() # comment

tests/testthat/line_breaks_fun_call/blank-strict-out.R

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ call(
1919
2,
2020

2121

22-
2322
# comment
2423

2524
1,

tests/testthat/line_breaks_fun_call/switch_ifelse_etc_no_line_break-out.R

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ switch( #
1616
)
1717

1818

19-
2019
switch(x,
2120
a = 2, #
2221
y = 3

tests/testthat/line_breaks_fun_call/token_dependent_mixed-out.R

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ call(call(
1616
))
1717

1818

19-
2019
# no more barcket on same line ->
2120
call(call(
2221
3, 4

0 commit comments

Comments
 (0)