Skip to content

Commit cc83782

Browse files
committed
Use the base R anonymous function syntax
1 parent a89f521 commit cc83782

11 files changed

+28
-24
lines changed

R/browse.R

+5-4
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ browse_package <- function(package = NULL) {
7979
)
8080
details <- c(
8181
details,
82-
map(parsed$name, ~ cli::cli_fmt(cli::cli_text("{.val {.x}} remote")))
82+
map(parsed$name, \(x) cli::cli_fmt(cli::cli_text("{.val {x}} remote")))
8383
)
8484
}
8585

@@ -89,8 +89,9 @@ browse_package <- function(package = NULL) {
8989
details,
9090
map(
9191
desc_urls_dat$desc_field,
92-
~ if (is.na(.x)) "CRAN" else
93-
cli::cli_fmt(cli::cli_text("{.field {.x}} field in DESCRIPTION"))
92+
\(x)
93+
if (is.na(x)) "CRAN" else
94+
cli::cli_fmt(cli::cli_text("{.field {x}} field in DESCRIPTION"))
9495
)
9596
)
9697
if (length(urls) == 0) {
@@ -106,7 +107,7 @@ browse_package <- function(package = NULL) {
106107
pretty <- purrr::map2(
107108
format(urls, justify = "left"),
108109
details,
109-
~ glue("{.x} ({.y})")
110+
\(x, y) glue("{x} ({y})")
110111
)
111112
choice <- utils::menu(title = prompt, choices = pretty)
112113
if (choice == 0) {

R/git-default-branch.R

+3-1
Original file line numberDiff line numberDiff line change
@@ -650,7 +650,9 @@ fishy_bookdown_config <- function(old_name = "master") {
650650
return(invisible(character()))
651651
}
652652
# I am (very weakly) worried about more than 1 match, hence the [[1]]
653-
bookdown_config <- purrr::discard(bookdown_config, ~ grepl("revdep", .x))[[1]]
653+
bookdown_config <- purrr::discard(bookdown_config, \(x) grepl("revdep", x))[[
654+
1
655+
]]
654656

655657
bookdown_config_lines <- read_utf8(bookdown_config)
656658
linky_lines <- grep(

R/github-labels.R

+8-7
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ use_github_labels <- function(
115115
# Must first PATCH issues, then sort out labels
116116
issues <- map(
117117
to_rename,
118-
~ gh("GET /repos/{owner}/{repo}/issues", labels = .x)
118+
\(x) gh("GET /repos/{owner}/{repo}/issues", labels = x)
119119
)
120120
issues <- purrr::flatten(issues)
121121
number <- map_int(issues, "number")
@@ -133,17 +133,18 @@ use_github_labels <- function(
133133
new_labels <- split(df$labels, df$number)
134134
purrr::iwalk(
135135
new_labels,
136-
~ gh(
137-
"PATCH /repos/{owner}/{repo}/issues/{issue_number}",
138-
issue_number = .y,
139-
labels = I(.x)
140-
)
136+
\(x, y)
137+
gh(
138+
"PATCH /repos/{owner}/{repo}/issues/{issue_number}",
139+
issue_number = y,
140+
labels = I(x)
141+
)
141142
)
142143

143144
# issues have correct labels now; safe to edit labels themselves
144145
purrr::walk(
145146
to_rename,
146-
~ gh("DELETE /repos/{owner}/{repo}/labels/{name}", name = .x)
147+
\(x) gh("DELETE /repos/{owner}/{repo}/labels/{name}", name = x)
147148
)
148149
labels <- union(labels, setdiff(rename, cur_label_names))
149150
} else {

R/github_token.R

+1-1
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ pat_sitrep <- function(
205205
emails <- maybe_emails$result
206206
addresses <- map_chr(
207207
emails,
208-
~ if (.x$primary) glue_data(.x, "{email} (primary)") else .x[["email"]]
208+
\(x) if (x$primary) glue_data(x, "{email} (primary)") else x[["email"]]
209209
)
210210
kv_line("Email(s)", addresses)
211211
ui_silence(

R/latest-dependencies.R

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ update_versions <- function(
4343
packages <- deps$package[to_change]
4444
versions <- switch(
4545
match.arg(source),
46-
local = map_chr(packages, ~ as.character(utils::packageVersion(.x))),
46+
local = map_chr(packages, \(x) as.character(utils::packageVersion(x))),
4747
CRAN = utils::available.packages()[packages, "Version"]
4848
)
4949
deps$version[to_change] <- paste0(">= ", versions)

R/package.R

+1-1
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ use_remote <- function(package, package_remote = NULL) {
101101
package_remote <- function(desc) {
102102
remote <- as.list(desc$get(c("RemoteType", "RemoteUsername", "RemoteRepo")))
103103

104-
is_recognized_remote <- all(map_lgl(remote, ~ is_string(.x) && !is.na(.x)))
104+
is_recognized_remote <- all(map_lgl(remote, \(x) is_string(x) && !is.na(x)))
105105

106106
if (is_recognized_remote) {
107107
# non-GitHub remotes get a 'RemoteType::' prefix

R/pr.R

+3-3
Original file line numberDiff line numberDiff line change
@@ -832,7 +832,7 @@ pr_list <- function(
832832
prs <- list(list())
833833
}
834834
out <- map(prs, pr_data_tidy)
835-
out <- map(out, ~ as.data.frame(.x, stringsAsFactors = FALSE))
835+
out <- map(out, \(x) as.data.frame(x, stringsAsFactors = FALSE))
836836
out <- do.call(rbind, out)
837837
if (no_prs) {
838838
out[0, ]
@@ -860,7 +860,7 @@ branches_with_no_upstream_or_github_upstream <- function(tr = NULL) {
860860
gb_dat$ref <- remref_branch(gb_dat$remref)
861861
gb_dat$cfg_pr_url <- map_chr(
862862
glue("branch.{gb_dat$name}.pr-url"),
863-
~ git_cfg_get(.x, where = "local") %||% NA_character_
863+
\(x) git_cfg_get(x, where = "local") %||% NA_character_
864864
)
865865

866866
ghr <- github_remote_list(these = NULL)[["remote"]]
@@ -882,7 +882,7 @@ branches_with_no_upstream_or_github_upstream <- function(tr = NULL) {
882882
purrr::walk2(
883883
glue("branch.{dat$name[missing_cfg]}.pr-url"),
884884
dat$pr_html_url[missing_cfg],
885-
~ gert::git_config_set(.x, .y, repo = repo)
885+
\(x, y) gert::git_config_set(x, y, repo = repo)
886886
)
887887

888888
dat

R/release.R

+1-1
Original file line numberDiff line numberDiff line change
@@ -534,7 +534,7 @@ is_in_posit_org <- function() {
534534
urls <- desc$get_urls()
535535
dat <- parse_github_remotes(urls)
536536
dat <- dat[dat$host == "github.com", ]
537-
purrr::some(dat$repo_owner, ~ .x %in% posit_orgs())
537+
purrr::some(dat$repo_owner, \(x) x %in% posit_orgs())
538538
}
539539

540540
posit_orgs <- function() {

R/utils-git.R

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ gert_shush <- function(expr, regexp) {
44
check_character(regexp)
55
withCallingHandlers(
66
gertMessage = function(cnd) {
7-
m <- map_lgl(regexp, ~ grepl(.x, cnd_message(cnd), perl = TRUE))
7+
m <- map_lgl(regexp, \(x) grepl(x, cnd_message(cnd), perl = TRUE))
88
if (any(m)) {
99
cnd_muffle(cnd)
1010
}

R/utils-github.R

+3-3
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ github_remotes <- function(
205205
# NOTE: these can be two separate matters:
206206
# 1. Did we call the GitHub API? Means we know `is_fork` and the parent repo.
207207
# 2. If so, did we call it with auth? Means we know if we can push.
208-
grl$github_got <- map_lgl(repo_info, ~ length(.x) > 0)
208+
grl$github_got <- map_lgl(repo_info, \(x) length(x) > 0)
209209
if (isTRUE(github_get) && !all(grl$github_got)) {
210210
oops <- which(!grl$github_got)
211211
oops_remotes <- grl$remote[oops]
@@ -235,7 +235,7 @@ github_remotes <- function(
235235
parent_info <- purrr::pmap(
236236
set_names(
237237
grl[c("parent_repo_owner", "parent_repo_name", "api_url")],
238-
~ sub("parent_", "", .x)
238+
\(x) sub("parent_", "", x)
239239
),
240240
get_gh_repo
241241
)
@@ -325,7 +325,7 @@ new_github_remote_config <- function() {
325325
)
326326
)
327327
# 0-row df --> a well-named list of properly typed NAs
328-
ptype <- map(ptype, ~ c(NA, .x))
328+
ptype <- map(ptype, \(x) c(NA, x))
329329
structure(
330330
list(
331331
type = NA_character_,

R/vscode.R

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use_vscode_debug <- function(open = rlang::is_interactive()) {
55
deps <- proj_deps()
66
lt_pkgs <- deps$package[deps$type == "LinkingTo"]
77
possibly_path_package <- purrr::possibly(path_package, otherwise = NA)
8-
lt_paths <- map_chr(lt_pkgs, ~ possibly_path_package(.x, "include"))
8+
lt_paths <- map_chr(lt_pkgs, \(x) possibly_path_package(x, "include"))
99
lt_paths <- purrr::discard(lt_paths, is.na)
1010
# this is a bit fiddly, but it produces the desired JSON when lt_paths has
1111
# length 0 or > 0

0 commit comments

Comments
 (0)