Skip to content

Commit 58f852d

Browse files
Merge pull request #630 from lorenzwalthert/issue-549
- No blank lines in function headers (#549).
2 parents 1d299f2 + e8ad27b commit 58f852d

File tree

8 files changed

+210
-111
lines changed

8 files changed

+210
-111
lines changed

.pre-commit-config.yaml

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,20 @@
11
# All available hooks: https://pre-commit.com/hooks.html
2+
# R specific hooks: https://github.com/lorenzwalthert/precommit
23
repos:
34
- repo: https://github.com/lorenzwalthert/precommit
4-
rev: v0.0.0.9027
5+
rev: v0.0.0.9038
56
hooks:
6-
# - id: lintr
7-
# - id: style-files Does style *-in.R files in tests otherwise!
87
- id: parsable-R
98
- id: no-browser-statement
9+
# - id: lintr
1010
- id: readme-rmd-rendered
11-
# R package development
12-
- id: roxygenize
13-
- id: use-tidy-description
14-
- id: deps-in-desc
11+
- id: spell-check
12+
- id: style-files
13+
args: [--style_pkg=styler, --style_fun=tidyverse_style]
1514
- repo: https://github.com/pre-commit/pre-commit-hooks
16-
rev: v2.4.0
15+
rev: v2.5.0
1716
hooks:
1817
- id: check-added-large-files
1918
args: ['--maxkb=200']
20-
- repo: https://github.com/lorenzwalthert/precommit-markdown-link-check
21-
rev: v0.0.0.9002 # Use the sha / tag you want to point at
22-
hooks:
23-
- id: markdown-link-check
19+
- id: end-of-file-fixer
20+
exclude: '\.Rd'

NEWS.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
## Major changes
44

5+
- blank lines in function calls and headers are now removed (#629, #630).
56

67
## Minor chnages and fixes
78

@@ -10,7 +11,6 @@
1011
- typos in documentation (#618, #614).
1112

1213

13-
1414
# styler 1.3.2
1515

1616
Release upon request by the CRAN team.
@@ -435,4 +435,3 @@ specify_reindention(
435435
)
436436
initialize_default_attributes(pd_flat)
437437
```
438-

R/rules-line-break.R

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,9 +170,10 @@ remove_line_break_before_round_closing_after_curly <- function(pd) {
170170
pd
171171
}
172172

173-
remove_line_break_before_round_closing_fun_dec <- function(pd) {
173+
remove_line_breaks_in_fun_dec <- function(pd) {
174174
if (is_function_dec(pd)) {
175175
round_after <- pd$token == "')'" & pd$token_before != "COMMENT"
176+
pd$lag_newlines[pd$lag_newlines > 1L] <- 1L
176177
pd$lag_newlines[round_after] <- 0L
177178
}
178179
pd

R/style-guides.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,8 @@ tidyverse_style <- function(scope = "tokens",
117117
set_line_break_before_curly_opening,
118118
remove_line_break_before_round_closing_after_curly =
119119
if (strict) remove_line_break_before_round_closing_after_curly,
120-
remove_line_break_before_round_closing_fun_dec =
121-
if (strict) remove_line_break_before_round_closing_fun_dec,
120+
remove_line_breaks_in_fun_dec =
121+
if (strict) remove_line_breaks_in_fun_dec,
122122
style_line_break_around_curly = partial(
123123
style_line_break_around_curly,
124124
strict

inst/WORDLIST

Lines changed: 77 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -1,80 +1,84 @@
1-
yihui
2-
xfun
3-
Visit'em
4-
unnest
5-
unlinkunindention
6-
unindent
7-
unindent
8-
unexplainable
9-
uncached
10-
Tidyverse
11-
tidyverse
12-
tidyeval
13-
tibbles
14-
tibble
15-
testthat
16-
stylerignore
17-
stylerignored
18-
StackOverflow
19-
Rprofile
20-
rprofile
21-
rplumber
22-
Roxygen
23-
roxygen
24-
Rnw
25-
rnw
26-
Rmd
27-
rmd
28-
RMarkdown
29-
rlang
30-
reprex
31-
reindention
32-
reindented
33-
rebased
34-
README
35-
readme
36-
rds
37-
precommit
38-
pre
39-
pos
40-
pkgdown
41-
parsable
42-
NUM
43-
macOS
44-
lorenzwalthert
45-
lifecycle
46-
LF
47-
levelName
48-
knitr
49-
ixmypi
50-
invasiveness
51-
innode
52-
infinitively
53-
https
54-
forcond
55-
filetype
56-
expr EQ
57-
EOLs
58-
EOL
59-
EOF
60-
emacs
61-
DSLs
62-
dontshowdontrun
63-
donttest
64-
dont
65-
dir
66-
dec
67-
cran
68-
CONST
69-
config
70-
codecov
71-
CMD
72-
cancelling
73-
741
Addin
752
Addins
763
AppVeyor
774
apriori
785
arg
796
AST
807
benchmarking
8+
cancelling
9+
chnages
10+
CMD
11+
codecov
12+
config
13+
CONST
14+
cran
15+
dec
16+
dir
17+
dont
18+
dontshowdontrun
19+
donttest
20+
DSLs
21+
emacs
22+
EOF
23+
EOL
24+
EOLs
25+
expr
26+
expr EQ
27+
filetype
28+
forcond
29+
funct
30+
https
31+
infinitively
32+
innode
33+
invasiveness
34+
ixmypi
35+
knitr
36+
levelName
37+
LF
38+
lifecycle
39+
lorenzwalthert
40+
macOS
41+
NUM
42+
parsable
43+
pgkdown
44+
pkgdown
45+
pos
46+
pre
47+
precommit
48+
rds
49+
readme
50+
README
51+
rebased
52+
reindented
53+
reindention
54+
reprex
55+
rlang
56+
RMarkdown
57+
rmd
58+
Rmd
59+
rnw
60+
Rnw
61+
roxygen
62+
Roxygen
63+
rplumber
64+
rprofile
65+
Rprofile
66+
StackOverflow
67+
styler
68+
stylerignore
69+
stylerignored
70+
stylers
71+
testthat
72+
tibble
73+
tibbles
74+
tidyeval
75+
tidyverse
76+
Tidyverse
77+
uncached
78+
unexplainable
79+
unindent
80+
unlinkunindention
81+
unnest
82+
Visit'em
83+
xfun
84+
yihui

tests/testthat/fun_dec/line_break_fun_dec-in.R

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
a <- function(x, #
2-
y
3-
) {
2+
y) {
43
x - 1
54
}
65

@@ -13,6 +12,24 @@ a <- function(x, #
1312

1413
a <- function(x, #
1514
y #
16-
) {
15+
) {
1716
y
1817
}
18+
19+
20+
a <- function(x,
21+
y) {
22+
x - 1
23+
}
24+
25+
a <- function(x,
26+
#
27+
y) {
28+
x - 1
29+
}
30+
31+
a <- function(x,
32+
33+
y) {
34+
x - 1
35+
}

tests/testthat/fun_dec/line_break_fun_dec-in_tree

Lines changed: 82 additions & 18 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/testthat/fun_dec/line_break_fun_dec-out.R

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,20 @@ a <- function(x, #
1515
) {
1616
y
1717
}
18+
19+
20+
a <- function(x,
21+
y) {
22+
x - 1
23+
}
24+
25+
a <- function(x,
26+
#
27+
y) {
28+
x - 1
29+
}
30+
31+
a <- function(x,
32+
y) {
33+
x - 1
34+
}

0 commit comments

Comments
 (0)