Skip to content

Commit ec22ce2

Browse files
committed
usethis::use_tidy_style()
1 parent a0fd244 commit ec22ce2

32 files changed

+129
-73
lines changed

R/compat-vctrs.R

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

1010
#' @export
1111
vec_restore.dribble <- function(x, to, ...) {
12-
dribble_maybe_reconstruct(x)
12+
dribble_maybe_reconstruct(x)
1313
}
1414

1515
# ------------------------------------------------------------------------------

R/dribble.R

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -212,10 +212,12 @@ as_dribble.data.frame <- function(x, ...) validate_dribble(new_dribble(x))
212212

213213
#' @export
214214
as_dribble.list <- function(x, ...) {
215-
if (length(x) == 0) return(dribble())
215+
if (length(x) == 0) {
216+
return(dribble())
217+
}
216218

217219
required_nms <- c("name", "id", "kind")
218-
stopifnot(map_lgl(x, ~all(required_nms %in% names(.x))))
220+
stopifnot(map_lgl(x, ~ all(required_nms %in% names(.x))))
219221

220222
as_dribble(
221223
tibble(
@@ -248,7 +250,8 @@ as_parent <- function(d) {
248250
if (is_folder_shortcut(d)) {
249251
drive_bullets(c(
250252
i = "Parent specified via {.arg {in_var}} is a shortcut; resolving to \\
251-
its target folder"))
253+
its target folder"
254+
))
252255
d <- shortcut_resolve(d)
253256
}
254257
if (!is_parental(d)) {

R/drive_auth.R

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,6 @@ drive_has_token <- function() {
169169
#' drive_oauth_app()
170170
#' drive_api_key()
171171
#' }
172-
#'
173172
#' \dontrun{
174173
#' # bring your own app via JSON downloaded from Google Developers Console
175174
#' drive_auth_configure(
@@ -259,9 +258,12 @@ local_deauth <- function(env = parent.frame()) {
259258
drive_bullets(c("i" = "Restoring previous auth state.")),
260259
envir = env
261260
)
262-
withr::defer({
263-
.auth$set_cred(original_cred)
264-
.auth$set_auth_active(original_auth_active)
265-
}, envir = env)
261+
withr::defer(
262+
{
263+
.auth$set_cred(original_cred)
264+
.auth$set_auth_active(original_auth_active)
265+
},
266+
envir = env
267+
)
266268
drive_deauth()
267269
}

R/drive_browse.R

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@ drive_link <- function(file) {
4343
drive_browse <- function(file = .Last.value) {
4444
file <- as_dribble(file)
4545
links <- drive_link(file)
46-
if (!interactive() || no_file(file)) return(invisible(links))
46+
if (!interactive() || no_file(file)) {
47+
return(invisible(links))
48+
}
4749
if (!single_file(file)) {
4850
drive_bullets(c("v" = "Browsing the first file of {nrow(file)}."))
4951
}

R/drive_create.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ drive_create <- function(name,
117117
"Created Drive file:",
118118
bulletize(gargle_map_cli(out)),
119119
"With MIME type:",
120-
bulletize(gargle_map_cli(purrr::pluck(out, 'drive_resource', 1, 'mimeType')))
120+
bulletize(gargle_map_cli(purrr::pluck(out, "drive_resource", 1, "mimeType")))
121121
))
122122
invisible(out)
123123
}

R/drive_find.R

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,10 @@
103103
#'
104104
#' # various ways to specify q search clauses
105105
#' # multiple q's
106-
#' drive_find(q = "name contains 'TEST'",
107-
#' q = "modifiedTime > '2020-07-21T12:00:00'")
106+
#' drive_find(
107+
#' q = "name contains 'TEST'",
108+
#' q = "modifiedTime > '2020-07-21T12:00:00'"
109+
#' )
108110
#' # vector q
109111
#' drive_find(q = c("starred = true", "visibility = 'anyoneWithLink'"))
110112
#'
@@ -149,7 +151,9 @@ drive_find <- function(pattern = NULL,
149151
shared_drive <- shared_drive %||% team_drive
150152
}
151153

152-
if (n_max < 1) return(dribble())
154+
if (n_max < 1) {
155+
return(dribble())
156+
}
153157

154158
params <- toCamel(list2(...))
155159
params[["fields"]] <- params[["fields"]] %||% "*"
@@ -239,6 +243,8 @@ handle_shared_drives <- function(shared_drive, corpus) {
239243
)
240244
corpus <- "allDrives"
241245
}
242-
if (is.null(shared_drive) && is.null(corpus)) return()
246+
if (is.null(shared_drive) && is.null(corpus)) {
247+
return()
248+
}
243249
shared_drive_params(shared_drive, corpus)
244250
}

R/drive_get.R

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,9 @@ drive_get <- function(path = NULL,
123123
verbose = deprecated(),
124124
team_drive = deprecated()) {
125125
warn_for_verbose(verbose)
126-
if (length(path) + length(id) == 0) return(dribble_with_path())
126+
if (length(path) + length(id) == 0) {
127+
return(dribble_with_path())
128+
}
127129
stopifnot(is.null(path) || is.character(path))
128130
stopifnot(is.null(id) || is.character(id))
129131

R/drive_get_path.R

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44

55
drive_reveal_path <- function(x, ancestors = c("none", "parents", "all")) {
66
stopifnot(inherits(x, "dribble"))
7-
if (no_file(x)) return(dribble_with_path())
7+
if (no_file(x)) {
8+
return(dribble_with_path())
9+
}
810
ancestors <- ancestors %||% dribble()
911

1012
if (!inherits(ancestors, "dribble")) {
@@ -48,7 +50,9 @@ sort_out_shared_drive_and_corpus <- function(x) {
4850
drive_get_path <- function(path = NULL,
4951
shared_drive = NULL,
5052
corpus = NULL) {
51-
if (length(path) == 0) return(dribble_with_path())
53+
if (length(path) == 0) {
54+
return(dribble_with_path())
55+
}
5256
stopifnot(is_path(path))
5357
path <- rootize_path(path)
5458

@@ -125,7 +129,7 @@ get_immediate_parents <- function(x) {
125129
resolve_paths <- function(d, folders = dribble()) {
126130
probands <- pthize(d)
127131
ancestors <- pthize(folders)
128-
raw_paths <- map(probands, ~pth(list(.x), ancestors))
132+
raw_paths <- map(probands, ~ pth(list(.x), ancestors))
129133
pretty_paths <- map_chr(raw_paths, pathify)
130134
put_column(d, nm = "path", val = pretty_paths, .after = "name")
131135
}
@@ -146,16 +150,19 @@ pthize <- function(d) {
146150

147151
# turns the output of pth() (a list) into a filepath (a string)
148152
pathify <- function(x) {
149-
x <- map_if(x, ~ .x$id == root_id(), ~ {.x$name <- "~"; .x})
153+
x <- map_if(x, ~ .x$id == root_id(), ~ {
154+
.x$name <- "~"
155+
.x
156+
})
150157

151158
last_mime_type <- pluck(last(x), "mime_type")
152159
last_is_folder <- identical(last_mime_type, drive_mime_type("folder"))
153160
last_is_folder_shortcut <-
154161
identical(last_mime_type, drive_mime_type("shortcut")) &&
155-
identical(
156-
pluck(last(x), "shortcut_details", "targetMimeType"),
157-
drive_mime_type("folder")
158-
)
162+
identical(
163+
pluck(last(x), "shortcut_details", "targetMimeType"),
164+
drive_mime_type("folder")
165+
)
159166
if (last_is_folder || last_is_folder_shortcut) {
160167
nm <- pluck(last(x), "name")
161168
purrr::pluck(x, length(x), "name") <- append_slash(nm)
@@ -216,7 +223,9 @@ finalize <- function(dat, candidates) {
216223

217224
report_weird_stuff <- function(x, indicator, problem) {
218225
weird <- vec_slice(x, x[["status"]] == indicator)
219-
if (vec_size(weird) == 0) return()
226+
if (vec_size(weird) == 0) {
227+
return()
228+
}
220229
drive_bullets(c(
221230
"!" = "Problem with {nrow(weird)} path{?s}: {problem}",
222231
# these really should be sub-bullets, but not possible at this time
@@ -231,7 +240,8 @@ finalize <- function(dat, candidates) {
231240
if (n_empty_string > 0) {
232241
drive_bullets(c(
233242
"!" = "Problem with {n_empty_string} path{?s}: \\
234-
path is empty string"))
243+
path is empty string"
244+
))
235245
}
236246

237247
index <- unlist(scratch$m)
@@ -280,7 +290,7 @@ get_by_name <- function(names, shared_drive = NULL, corpus = NULL) {
280290
} else {
281291
found <- drive_find(
282292
q = or(q_clauses),
283-
#fields = prep_fields(fields),
293+
# fields = prep_fields(fields),
284294
shared_drive = shared_drive, corpus = corpus
285295
)
286296
}
@@ -302,7 +312,7 @@ get_last_path_part <- function(path) {
302312
# why? googledrive encourages the user to use a trailing slash to explicitly
303313
# indicate a path that refers to a folder
304314
slash_pos <- gregexpr(pattern = "/.", path)
305-
no_slash <- map_lgl(slash_pos, ~all(.x == -1))
315+
no_slash <- map_lgl(slash_pos, ~ all(.x == -1))
306316
last_slash <- map_int(slash_pos, max)
307317
ifelse(no_slash, path, substr(path, last_slash + 1, nchar(path)))
308318
}

R/drive_id-class.R

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,9 @@ as_id.data.frame <- function(x, ...) as_id(validate_dribble(new_dribble(x)))
7272

7373
#' @export
7474
as_id.character <- function(x, ...) {
75-
if (length(x) == 0L) return(new_drive_id())
75+
if (length(x) == 0L) {
76+
return(new_drive_id())
77+
}
7678
out <- map_chr(x, get_one_id)
7779
validate_drive_id(new_drive_id(out))
7880
}
@@ -134,7 +136,9 @@ id_regexp <- "(/d/|/folders/|id=)[^/]+"
134136
is_drive_url <- function(x) grepl("^http", x) & grepl(id_regexp, x)
135137

136138
get_one_id <- function(x) {
137-
if (!grepl("^http|/", x)) return(x)
139+
if (!grepl("^http|/", x)) {
140+
return(x)
141+
}
138142

139143
id_loc <- regexpr(id_regexp, x)
140144
if (id_loc == -1) {

R/drive_mkdir.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
#' drive_mkdir("name-squatter-mkdir", path = ghi, overwrite = TRUE)
4242
#'
4343
#' # list everything inside 'ghi'
44-
#' drive_ls('ghi')
44+
#' drive_ls("ghi")
4545
#'
4646
#' # Clean up
4747
#' drive_rm(ghi)

0 commit comments

Comments
 (0)