Skip to content

Commit e35bc18

Browse files
Merge branch 'main' into f-759-named-funs
2 parents 00d46c2 + 340e07b commit e35bc18

25 files changed

+866
-147
lines changed

.github/workflows/check-full.yaml

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,12 @@ jobs:
2727
- {os: windows-latest, r: '3.6'}
2828

2929
# Use older ubuntu to maximise backward compatibility
30-
- {os: ubuntu-18.04, r: 'devel', http-user-agent: 'release'}
31-
- {os: ubuntu-18.04, r: 'release'}
32-
- {os: ubuntu-18.04, r: 'oldrel-1'}
33-
- {os: ubuntu-18.04, r: 'oldrel-2'}
34-
- {os: ubuntu-18.04, r: 'oldrel-3'}
35-
- {os: ubuntu-18.04, r: 'oldrel-4'}
30+
- {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'}
31+
- {os: ubuntu-latest, r: 'release'}
32+
- {os: ubuntu-latest, r: 'oldrel-1'}
33+
- {os: ubuntu-latest, r: 'oldrel-2'}
34+
- {os: ubuntu-latest, r: 'oldrel-3'}
35+
- {os: ubuntu-latest, r: 'oldrel-4'}
3636

3737
env:
3838
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
@@ -51,10 +51,12 @@ jobs:
5151

5252
- uses: r-lib/actions/setup-r-dependencies@v2
5353
with:
54-
extra-packages: any::rcmdcheck, data.tree=?ignore-before-r=3.5.0
54+
extra-packages: any::rcmdcheck
5555
needs: check
5656

5757
- uses: r-lib/actions/check-r-package@v2
58+
with:
59+
error-on: '"note"'
5860
env:
5961
_R_CHECK_FORCE_SUGGESTS_: false
6062

.github/workflows/pre-commit.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ on:
99

1010
jobs:
1111
pre-commit:
12-
runs-on: ubuntu-18.04
12+
runs-on: ubuntu-latest
1313
if: >-
1414
!contains(github.event.head_commit.message, 'ci skip') &&
1515
(

DESCRIPTION

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,19 @@ Authors@R:
1111
person(given = "Lorenz",
1212
family = "Walthert",
1313
role = c("cre", "aut"),
14-
email = "[email protected]"))
14+
email = "[email protected]"),
15+
person(given = "Indrajeet",
16+
family = "Patil",
17+
role = "ctb",
18+
email = "[email protected]",
19+
comment = c(ORCID = "0000-0003-1995-6531", Twitter = "@patilindrajeets")))
1520
Description: Pretty-prints R code without changing the user's formatting
1621
intent.
1722
License: MIT + file LICENSE
1823
URL: https://github.com/r-lib/styler, https://styler.r-lib.org
1924
BugReports: https://github.com/r-lib/styler/issues
2025
Depends:
21-
R (>= 3.4.0)
26+
R (>= 3.5.0)
2227
Imports:
2328
cli (>= 3.1.1),
2429
magrittr (>= 2.0.0),
@@ -48,6 +53,7 @@ Roxygen: list(markdown = TRUE, roclets = c("rd", "namespace", "collate",
4853
"pkgapi::api_roclet"))
4954
RoxygenNote: 7.2.1
5055
Config/testthat/edition: 3
56+
Config/testthat/parallel: true
5157
Collate:
5258
'addins.R'
5359
'communicate.R'

NEWS.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ editor_options:
1111
- `style_dir()` and `style_pkg()` now default to styling all supported file
1212
formats (`.R`, `.Rmd`, `.Rmarkdown`, `.Rnw`, and `.qmd`) in the (package)
1313
directory (\@IndrajeetPatil, #965).
14-
- `style_pkg()` now excludes the auto-generated `R/cpp11.R` file (#977).
14+
- `style_pkg()` now excludes the auto-generated `R/cpp11.R` file (#977).
15+
- Minimum needed R version is now bumped to `3.5` (\@IndrajeetPatil, #986).
1516

1617
**Features**
1718

@@ -49,6 +50,10 @@ editor_options:
4950

5051
**Other**
5152

53+
- \@IndrajeetPatil is now a contributor to {styler}. Welcome and thanks for
54+
everything you did so far! (#988).
55+
- Non-exported and unused functions `odd()` and `even()` were removed
56+
(\@IndrajeetPatil, #989).
5257
- Old (and outdated) vignettes have been removed (\@IndrajeetPatil, #955). To
5358
access them, do `git checkout v1.0.0`.
5459
- Upgrade testing infra to testthat 3e (\@IndrajeetPatil, #949).
@@ -628,7 +633,7 @@ Thanks to all contributors involved, in particular
628633
## Adaption
629634

630635
- styler is now available through the pre-commit hook `style-files` in
631-
<https://github.com/lorenzwalthert/pre-commit-hooks>.
636+
<https://github.com/lorenzwalthert/precommit>.
632637

633638
Thanks to all contributors involved, in particular
634639

R/expr-is.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ is_subset_expr <- function(pd) {
103103
#' Identify comments that are shebangs
104104
#'
105105
#' Shebangs should be preserved and no space should be inserted between
106-
#' \# and !. A comment is a shebang if it is the first top level token
106+
#' `#` and `!`. A comment is a shebang if it is the first top level token
107107
#' (identified with `pos_id`) and if it starts with `#!`.
108108
#' @param pd A parse table.
109109
#' @examples

R/nest.R

Lines changed: 26 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -250,13 +250,15 @@ add_terminal_token_after <- function(pd_flat) {
250250
filter(terminal) %>%
251251
arrange_pos_id()
252252

253-
new_tibble(list(
254-
pos_id = terminals$pos_id,
255-
token_after = lead(terminals$token, default = "")
256-
),
257-
nrow = nrow(terminals)
258-
) %>%
259-
left_join(pd_flat, ., by = "pos_id")
253+
rhs <- new_tibble(
254+
list(
255+
pos_id = terminals$pos_id,
256+
token_after = lead(terminals$token, default = "")
257+
),
258+
nrow = nrow(terminals)
259+
)
260+
261+
left_join(pd_flat, rhs, by = "pos_id")
260262
}
261263

262264
#' @rdname add_token_terminal
@@ -266,14 +268,15 @@ add_terminal_token_before <- function(pd_flat) {
266268
filter(terminal) %>%
267269
arrange_pos_id()
268270

269-
new_tibble(
271+
rhs <- new_tibble(
270272
list(
271273
id = terminals$id,
272274
token_before = lag(terminals$token, default = "")
273275
),
274276
nrow = nrow(terminals)
275-
) %>%
276-
left_join(pd_flat, ., by = "id")
277+
)
278+
279+
left_join(pd_flat, rhs, by = "id")
277280
}
278281

279282

@@ -351,13 +354,19 @@ nest_parse_data <- function(pd_flat) {
351354
internal$child <- NULL
352355

353356
child$parent_ <- child$parent
354-
joined <-
355-
child %>%
356-
nest_(., "child", setdiff(names(.), "parent_")) %>%
357-
left_join(internal, ., by = c("id" = "parent_"))
358-
nested <- joined
359-
nested$child <- map2(nested$child, nested$internal_child, combine_children)
360-
nested <- nested[, setdiff(names(nested), "internal_child")]
357+
358+
rhs <- nest_(child, "child", setdiff(names(child), "parent_"))
359+
360+
nested <- left_join(internal, rhs, by = c("id" = "parent_"))
361+
362+
children <- nested$child
363+
for (i in seq_along(children)) {
364+
new <- combine_children(children[[i]], nested$internal_child[[i]])
365+
# Work around is.null(new)
366+
children[i] <- list(new)
367+
}
368+
nested$child <- children
369+
nested$internal_child <- NULL
361370
nest_parse_data(nested)
362371
}
363372

R/roxygen-examples-parse.R

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,9 +146,8 @@ emulate_rd <- function(roxygen) {
146146
text <- roxygen2::roc_proc_text(
147147
roxygen2::rd_roclet(),
148148
paste(roxygen, collapse = "\n")
149-
)[[1]]$get_section("examples") %>%
150-
as.character() %>%
151-
.[-1]
149+
)[[1]]$get_section("examples")
150+
text <- as.character(text)[-1]
152151
text <- c(
153152
if (grepl("^#'(\\s|\t)*@examples(\\s|\t)*$", roxygen[2])) "",
154153
text

R/transform-files.R

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -244,15 +244,20 @@ parse_transform_serialize_r <- function(text,
244244
transformers
245245
)
246246

247-
text_out <- pd_nested %>%
248-
split(pd_nested$block) %>%
249-
unname() %>%
250-
map2(find_blank_lines_to_next_block(pd_nested),
251-
parse_transform_serialize_r_block,
247+
pd_split <- unname(split(pd_nested, pd_nested$block))
248+
pd_blank <- find_blank_lines_to_next_block(pd_nested)
249+
250+
text_out <- vector("list", length(pd_split))
251+
for (i in seq_along(pd_split)) {
252+
text_out[[i]] <- parse_transform_serialize_r_block(
253+
pd_split[[i]],
254+
pd_blank[[i]],
252255
transformers = transformers,
253256
base_indention = base_indention
254-
) %>%
255-
unlist()
257+
)
258+
}
259+
260+
text_out <- unlist(text_out)
256261

257262
verify_roundtrip(
258263
text, text_out,

R/utils.R

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -48,24 +48,13 @@ two_cols_match <- function(col1, col2, data) {
4848
all(unlist(data[col1]) == unlist(data[col2]))
4949
}
5050

51-
odd <- function(x) {
52-
x[odd_index(x)]
53-
}
54-
5551
odd_index <- function(x) {
5652
if (length(x) < 1) {
5753
return(NULL)
5854
}
5955
seq(1L, length(x), by = 2)
6056
}
6157

62-
even <- function(x) {
63-
if (length(x) < 2) {
64-
return(NULL)
65-
}
66-
x[even_index(x)]
67-
}
68-
6958
even_index <- function(x) {
7059
seq(2L, length(x), by = 2)
7160
}

cran-comments.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Luke Tierney.
1010

1111
## Test environments
1212

13-
- ubuntu 18.04 (on GitHub Actions): R devel, R 4.1.2, R 4.0.5, R 3.6, R 3.5,
13+
- ubuntu 20.04 (on GitHub Actions): R devel, R 4.1.2, R 4.0.5, R 3.6, R 3.5,
1414
R 3.4
1515
- Windows Server 10 (on GitHub Actions): R 3.6, R 4.0.5
1616
- win-builder: R devel

0 commit comments

Comments
 (0)