Skip to content

Commit 02acf5e

Browse files
chore: format everything with air (#392)
1 parent e81fa41 commit 02acf5e

File tree

87 files changed

+2130
-754
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

87 files changed

+2130
-754
lines changed

.lintr

+1-2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,5 @@ linters: linters_with_defaults(
99
exclusions: list(
1010
"tests/testthat/2024.07.0/",
1111
"tests/testthat/2024.08.0/",
12-
"tests/testthat/2024.09.0/",
13-
"inst/scratch/"
12+
"tests/testthat/2024.09.0/"
1413
)

DESCRIPTION

+26
Original file line numberDiff line numberDiff line change
@@ -66,3 +66,29 @@ Language: en-US
6666
RoxygenNote: 7.3.2
6767
Roxygen: list(markdown = TRUE)
6868
Config/testthat/edition: 3
69+
Collate:
70+
'audits.R'
71+
'browse.R'
72+
'connect.R'
73+
'connectapi-package.R'
74+
'connectapi.R'
75+
'content.R'
76+
'deploy.R'
77+
'get.R'
78+
'git.R'
79+
'groups.R'
80+
'lazy.R'
81+
'page.R'
82+
'parse.R'
83+
'promote.R'
84+
'ptype.R'
85+
'remote.R'
86+
'runtime-caches.R'
87+
'schedule.R'
88+
'tags.R'
89+
'utils.R'
90+
'thumbnail.R'
91+
'user.R'
92+
'utils-ci.R'
93+
'utils-pipe.R'
94+
'variant.R'

NAMESPACE

+1
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ importFrom(magrittr,"%>%")
159159
importFrom(rlang,"%||%")
160160
importFrom(rlang,":=")
161161
importFrom(rlang,arg_match)
162+
importFrom(rlang,is_string)
162163
importFrom(utils,browseURL)
163164
importFrom(utils,capture.output)
164165
importFrom(utils,compareVersion)

R/audits.R

+9-2
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,10 @@ audit_r_versions <- function(content) {
3939
stop("gridExtra is required for this function")
4040
}
4141

42-
timeline <- content[!is.na(content$r_version), c("r_version", "last_deployed_time")]
42+
timeline <- content[
43+
!is.na(content$r_version),
44+
c("r_version", "last_deployed_time")
45+
]
4346

4447
# histogram
4548
p1 <- ggplot2::ggplot(timeline) +
@@ -79,7 +82,11 @@ audit_r_versions <- function(content) {
7982
#' @family audit functions
8083
#' @export
8184
audit_runas <- function(content) {
82-
content$run_as <- ifelse(content$run_as_current_user, "current user", content$run_as)
85+
content$run_as <- ifelse(
86+
content$run_as_current_user,
87+
"current user",
88+
content$run_as
89+
)
8390
content <- content[!is.na(content$run_as), c("name", "run_as")]
8491
names(content) <- c("app_name", "run_as_user")
8592
content

R/connect.R

+126-62
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,9 @@ Connect <- R6::R6Class(
4747
initialize = function(server, api_key) {
4848
message(glue::glue("Defining Connect with server: {server}"))
4949
if (is.null(httr::parse_url(server)$scheme)) {
50-
stop(glue::glue("ERROR: Please provide a protocol (http / https). You gave: {server}"))
50+
stop(glue::glue(
51+
"ERROR: Please provide a protocol (http / https). You gave: {server}"
52+
))
5153
}
5254
self$server <- base::sub("^(.*)/$", "\\1", server)
5355
self$api_key <- api_key
@@ -179,13 +181,22 @@ Connect <- R6::R6Class(
179181
#' @param parser How the response is parsed. If `NULL`, the `httr_response`
180182
#' will be returned. Otherwise, the argument is forwarded to
181183
#' `httr::content(res, as = parser)`.
182-
PUT = function(path,
183-
body = "{}",
184-
...,
185-
url = self$api_url(path),
186-
encode = "json",
187-
parser = "parsed") {
188-
self$request("PUT", url, parser = parser, body = body, encode = encode, ...)
184+
PUT = function(
185+
path,
186+
body = "{}",
187+
...,
188+
url = self$api_url(path),
189+
encode = "json",
190+
parser = "parsed"
191+
) {
192+
self$request(
193+
"PUT",
194+
url,
195+
parser = parser,
196+
body = body,
197+
encode = encode,
198+
...
199+
)
189200
},
190201

191202
#' @description Perform an HTTP HEAD request of the named API path.
@@ -220,13 +231,22 @@ Connect <- R6::R6Class(
220231
#' @param parser How the response is parsed. If `NULL`, the `httr_response`
221232
#' will be returned. Otherwise, the argument is forwarded to
222233
#' `httr::content(res, as = parser)`.
223-
PATCH = function(path,
224-
body = "{}",
225-
...,
226-
url = self$api_url(path),
227-
encode = "json",
228-
parser = "parsed") {
229-
self$request("PATCH", url, parser = parser, body = body, encode = encode, ...)
234+
PATCH = function(
235+
path,
236+
body = "{}",
237+
...,
238+
url = self$api_url(path),
239+
encode = "json",
240+
parser = "parsed"
241+
) {
242+
self$request(
243+
"PATCH",
244+
url,
245+
parser = parser,
246+
body = body,
247+
encode = encode,
248+
...
249+
)
230250
},
231251

232252
#' @description Perform an HTTP POST request of the named API path.
@@ -239,13 +259,22 @@ Connect <- R6::R6Class(
239259
#' @param parser How the response is parsed. If `NULL`, the `httr_response`
240260
#' will be returned. Otherwise, the argument is forwarded to
241261
#' `httr::content(res, as = parser)`.
242-
POST = function(path,
243-
body = "{}",
244-
...,
245-
url = self$api_url(path),
246-
encode = "json",
247-
parser = "parsed") {
248-
self$request("POST", url, parser = parser, body = body, encode = encode, ...)
262+
POST = function(
263+
path,
264+
body = "{}",
265+
...,
266+
url = self$api_url(path),
267+
encode = "json",
268+
parser = "parsed"
269+
) {
270+
self$request(
271+
"POST",
272+
url,
273+
parser = parser,
274+
body = body,
275+
encode = encode,
276+
...
277+
)
249278
},
250279

251280
#' @description Perform an HTTP GET request of the "me" server endpoint.
@@ -363,15 +392,23 @@ Connect <- R6::R6Class(
363392
#' @param .collapse How multiple filters are combined.
364393
#' @param .limit The limit.
365394
#' @param page_size The page size.
366-
get_apps = function(filter = NULL, .collapse = "&", .limit = Inf, page_size = 25) {
395+
get_apps = function(
396+
filter = NULL,
397+
.collapse = "&",
398+
.limit = Inf,
399+
page_size = 25
400+
) {
367401
path <- unversioned_url("applications")
368402
query <- list(
369403
count = min(page_size, .limit)
370404
)
371405
if (!is.null(filter)) {
372-
query$filter <- paste(sapply(seq_along(filter), function(i) {
373-
sprintf("%s:%s", names(filter)[i], filter[[i]])
374-
}), collapse = .collapse)
406+
query$filter <- paste(
407+
sapply(seq_along(filter), function(i) {
408+
sprintf("%s:%s", names(filter)[i], filter[[i]])
409+
}),
410+
collapse = .collapse
411+
)
375412
}
376413

377414
prg <- optional_progress_bar(
@@ -453,7 +490,12 @@ Connect <- R6::R6Class(
453490
#' @param owner_guid The target content owner.
454491
#' @param name The target name.
455492
#' @param include Additional response fields.
456-
content = function(guid = NULL, owner_guid = NULL, name = NULL, include = "tags,owner") {
493+
content = function(
494+
guid = NULL,
495+
owner_guid = NULL,
496+
name = NULL,
497+
include = "tags,owner"
498+
) {
457499
if (!is.null(guid)) {
458500
return(self$GET(v1_url("content", guid)))
459501
}
@@ -553,14 +595,16 @@ Connect <- R6::R6Class(
553595
#' @param user_must_set_password Indicates that user sets password on first login.
554596
#' @param user_role Role for user.
555597
#' @param unique_id Identifier for user.
556-
users_create = function(username,
557-
email,
558-
first_name = NULL,
559-
last_name = NULL,
560-
password = NULL,
561-
user_must_set_password = NULL,
562-
user_role = NULL,
563-
unique_id = NULL) {
598+
users_create = function(
599+
username,
600+
email,
601+
first_name = NULL,
602+
last_name = NULL,
603+
password = NULL,
604+
user_must_set_password = NULL,
605+
user_role = NULL,
606+
unique_id = NULL
607+
) {
564608
path <- v1_url("users")
565609
self$POST(
566610
path = path,
@@ -708,14 +752,16 @@ Connect <- R6::R6Class(
708752
#' @param previous Previous item.
709753
#' @param nxt Next item.
710754
#' @param asc_order Indicates ascending result order.
711-
inst_content_visits = function(content_guid = NULL,
712-
min_data_version = NULL,
713-
from = NULL,
714-
to = NULL,
715-
limit = 500,
716-
previous = NULL,
717-
nxt = NULL,
718-
asc_order = TRUE) {
755+
inst_content_visits = function(
756+
content_guid = NULL,
757+
min_data_version = NULL,
758+
from = NULL,
759+
to = NULL,
760+
limit = 500,
761+
previous = NULL,
762+
nxt = NULL,
763+
asc_order = TRUE
764+
) {
719765
path <- v1_url("instrumentation", "content", "visits")
720766
query <- list(
721767
content_guid = content_guid,
@@ -744,14 +790,16 @@ Connect <- R6::R6Class(
744790
#' @param previous Previous item.
745791
#' @param nxt Next item.
746792
#' @param asc_order Indicates ascending result order.
747-
inst_shiny_usage = function(content_guid = NULL,
748-
min_data_version = NULL,
749-
from = NULL,
750-
to = NULL,
751-
limit = 500,
752-
previous = NULL,
753-
nxt = NULL,
754-
asc_order = TRUE) {
793+
inst_shiny_usage = function(
794+
content_guid = NULL,
795+
min_data_version = NULL,
796+
from = NULL,
797+
to = NULL,
798+
limit = 500,
799+
previous = NULL,
800+
nxt = NULL,
801+
asc_order = TRUE
802+
) {
755803
path <- v1_url("instrumentation", "shiny", "usage")
756804
query <- list(
757805
content_guid = content_guid,
@@ -785,7 +833,9 @@ Connect <- R6::R6Class(
785833
warn_experimental("repo_account")
786834
parsed_url <- httr::parse_url(host)
787835
if (is.null(parsed_url$scheme) || is.null(parsed_url$hostname)) {
788-
stop(glue::glue("Scheme and hostname must be provided (i.e. 'https://github.com'). You provided '{host}'"))
836+
stop(glue::glue(
837+
"Scheme and hostname must be provided (i.e. 'https://github.com'). You provided '{host}'"
838+
))
789839
}
790840
host <- glue::glue(parsed_url$scheme, "://", parsed_url$hostname)
791841
path <- unversioned_url("repo", "account")
@@ -815,7 +865,11 @@ Connect <- R6::R6Class(
815865
#' @param start Starting time.
816866
#' @param end Ending time.
817867
#' @param detailed Indicates detailed schedule information.
818-
schedules = function(start = Sys.time(), end = Sys.time() + 60 * 60 * 24 * 7, detailed = FALSE) {
868+
schedules = function(
869+
start = Sys.time(),
870+
end = Sys.time() + 60 * 60 * 24 * 7,
871+
detailed = FALSE
872+
) {
819873
warn_experimental("schedules")
820874
url <- v1_url("experimental", "schedules")
821875
query_params <- list(
@@ -860,7 +914,12 @@ Connect <- R6::R6Class(
860914
#' @param previous Previous item.
861915
#' @param nxt Next item.
862916
#' @param asc_order Indicates ascending result order.
863-
audit_logs = function(limit = 500, previous = NULL, nxt = NULL, asc_order = TRUE) {
917+
audit_logs = function(
918+
limit = 500,
919+
previous = NULL,
920+
nxt = NULL,
921+
asc_order = TRUE
922+
) {
864923
path <- v1_url("audit_logs")
865924
query <- list(
866925
limit = valid_page_size(limit),
@@ -880,7 +939,11 @@ Connect <- R6::R6Class(
880939

881940
#' @description Get R installations.
882941
server_settings_r = function() {
883-
lifecycle::deprecate_soft("0.3.1", "Connect$server_settings_r()", "get_runtimes()")
942+
lifecycle::deprecate_soft(
943+
"0.3.1",
944+
"Connect$server_settings_r()",
945+
"get_runtimes()"
946+
)
884947
self$GET(v1_url("server_settings", "r"))
885948
},
886949

@@ -964,13 +1027,14 @@ Connect <- R6::R6Class(
9641027
#'
9651028
#' @export
9661029
connect <- function(
967-
server = Sys.getenv(paste0(prefix, "_SERVER"), NA_character_),
968-
api_key = Sys.getenv(paste0(prefix, "_API_KEY"), NA_character_),
969-
token,
970-
token_local_testing_key = api_key,
971-
prefix = "CONNECT",
972-
...,
973-
.check_is_fatal = TRUE) {
1030+
server = Sys.getenv(paste0(prefix, "_SERVER"), NA_character_),
1031+
api_key = Sys.getenv(paste0(prefix, "_API_KEY"), NA_character_),
1032+
token,
1033+
token_local_testing_key = api_key,
1034+
prefix = "CONNECT",
1035+
...,
1036+
.check_is_fatal = TRUE
1037+
) {
9741038
if (is.null(api_key) || is.na(api_key) || nchar(api_key) == 0) {
9751039
msg <- "Invalid (empty) API key. Please provide a valid API key"
9761040
if (.check_is_fatal) {

R/connectapi.R

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#' @importFrom utils compareVersion untar
22
#' @importFrom lifecycle deprecate_warn
3-
#' @importFrom rlang arg_match
3+
#' @importFrom rlang arg_match is_string
44
"_PACKAGE"
55

66
# Even if we don't currently have any references to functions in lifecycle,

0 commit comments

Comments
 (0)