Skip to content

Commit 79fd178

Browse files
authored
Fix spacing (#515)
1 parent aa63997 commit 79fd178

26 files changed

+119
-125
lines changed

R/oauth-client.R

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,4 +240,3 @@ oauth_client_get_token <- function(client,
240240
resp <- oauth_flow_fetch(req, "client$token_url", error_call = error_call)
241241
exec(oauth_token, !!!resp)
242242
}
243-

R/oauth-flow.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
oauth_flow_fetch <- function(req, source, error_call = caller_env()) {
2-
req <- req_error(req, is_error = ~ FALSE)
2+
req <- req_error(req, is_error = ~FALSE)
33
resp <- req_perform(req, error_call = current_call())
44

55
oauth_flow_parse(resp, source, error_call = error_call)

R/req-cache.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ cache_exists <- function(req) {
9191
if (!req_policy_exists(req, "cache_path")) {
9292
return(FALSE)
9393
}
94-
94+
9595
path <- req_cache_path(req)
9696
if (!file.exists(path)) {
9797
return(FALSE)

R/req-cookies.R

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,3 @@ req_cookie_preserve <- function(req, path) {
3535
cookiefile = path
3636
)
3737
}
38-

R/req-perform-stream.R

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
21
#' Perform a request and handle data as it streams back
3-
#'
2+
#'
43
#' @description
54
#' After preparing a request, call `req_perform_stream()` to perform the request
65
#' and handle the result with a streaming callback. This is useful for
76
#' streaming HTTP APIs where potentially the stream never ends.
8-
#'
9-
#' The `callback` will only be called if the result is successful. If you need
7+
#'
8+
#' The `callback` will only be called if the result is successful. If you need
109
#' to stream an error response, you can use [req_error()] to suppress error
1110
#' handling so that the body is streamed to you.
1211
#'
@@ -73,10 +72,10 @@ req_perform_stream <- function(req,
7372
continue <- TRUE
7473
incomplete <- TRUE
7574
buf <- raw()
76-
77-
while(continue && isIncomplete(stream) && Sys.time() < stop_time) {
75+
76+
while (continue && isIncomplete(stream) && Sys.time() < stop_time) {
7877
buf <- c(buf, readBin(stream, raw(), buffer_kb * 1024))
79-
78+
8079
if (length(buf) > 0) {
8180
cut <- cut_points(buf)
8281
n <- length(cut)

R/req-perform.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
#' `options(httr2_progress = FALSE)`.
3131
#'
3232
#' @param req A [request].
33-
#' @param path Optionally, path to save body of the response. This is useful
33+
#' @param path Optionally, path to save body of the response. This is useful
3434
#' for large responses since it avoids storing the response in memory.
3535
#' @param mock A mocking function. If supplied, this function is called
3636
#' with the request. It should return either `NULL` (if it doesn't want to
@@ -105,7 +105,7 @@ req_perform <- function(
105105
throttle_delay(req)
106106

107107
delay <- 0
108-
while(tries < max_tries && Sys.time() < deadline) {
108+
while (tries < max_tries && Sys.time() < deadline) {
109109
sys_sleep(delay, "for retry backoff")
110110
n <- n + 1
111111

R/req-retries.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
#'
5757
#' # use a constant 10s delay after every failure
5858
#' request("http://example.com") |>
59-
#' req_retry(backoff = ~ 10)
59+
#' req_retry(backoff = ~10)
6060
#'
6161
#' # When rate-limited, GitHub's API returns a 403 with
6262
#' # `X-RateLimit-Remaining: 0` and an Unix time stored in the

R/resp-url.R

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,3 @@ resp_url_queries <- function(resp) {
4747

4848
url_parse(resp$url)$query
4949
}
50-

R/resp.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ new_response <- function(method,
102102

103103

104104
#' @export
105-
print.httr2_response <- function(x,...) {
105+
print.httr2_response <- function(x, ...) {
106106
cli::cli_text("{.cls {class(x)}}")
107107
cli::cli_text("{.strong {x$method}} {x$url}")
108108
cli::cli_text("{.field Status}: {x$status_code} {resp_status_desc(x)}")

R/url.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,11 +190,11 @@ format_query_param <- function(x,
190190
unclass(x)
191191
} else {
192192
x <- format(x, scientific = FALSE, trim = TRUE, justify = "none")
193-
curl::curl_escape(x)
193+
curl::curl_escape(x)
194194
}
195195
}
196196
check_query_param <- function(x, name, multi = FALSE, error_call = caller_env()) {
197-
if (inherits(x, "AsIs") ) {
197+
if (inherits(x, "AsIs")) {
198198
if (multi) {
199199
ok <- is.character(x)
200200
expected <- "a character vector"

R/utils.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ sys_sleep <- function(seconds,
6767
total = seconds * fps
6868
)
6969

70-
while({left <- start + seconds - cur_time(); left > 0}) {
70+
while ({left <- start + seconds - cur_time(); left > 0}) {
7171
Sys.sleep(min(1 / fps, left))
7272
cli::cli_progress_update(set = (seconds - left) * fps)
7373
}

man/req_retry.Rd

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/testthat/test-curl.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ test_that("captures key components of call", {
3131
)
3232

3333
# Captures flags
34-
expect_equal(curl_args("curl 'http://example.com' --verbose")$`--verbose`, TRUE)
34+
expect_equal(curl_args("curl 'http://example.com' --verbose")$`--verbose`, TRUE)
3535
})
3636

3737
test_that("can handle line breaks", {

tests/testthat/test-iterate.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ test_that("can choose to return on failure", {
8080

8181
test_that("checks its inputs", {
8282
req <- request_test()
83-
expect_snapshot(error = TRUE,{
83+
expect_snapshot(error = TRUE, {
8484
req_perform_iterative(1)
8585
req_perform_iterative(req, function(x, y) x + y)
8686
req_perform_iterative(req, function(resp, req) {}, path = 1)

tests/testthat/test-oauth-flow.R

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,3 @@ test_that("converts expires_in to numeric", {
3737
body <- oauth_flow_parse(resp, "test")
3838
expect_equal(body$expires_in, 20)
3939
})
40-

tests/testthat/test-parse.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ test_that("can parse media type", {
2626
test_that("can parse authenticate header", {
2727
header <- paste0(
2828
'Bearer realm="example",',
29-
'error="invalid_token",','
30-
error_description="The access token expired"'
29+
'error="invalid_token",',
30+
'error_description="The access token expired"'
3131
)
3232
out <- parse_www_authenticate(header)
3333
expect_equal(out$scheme, "Bearer")

tests/testthat/test-req-error.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ test_that("can customise error info", {
1212
req <- request_test()
1313
expect_equal(error_body(req, response(404)), NULL)
1414

15-
req <- req %>% req_error(body = ~ "Hi!")
15+
req <- req %>% req_error(body = ~"Hi!")
1616
expect_equal(error_body(req, response(404)), "Hi!")
1717
})
1818

tests/testthat/test-req-mock.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ test_that("can override requests through mocking", {
22
resp <- response()
33
req <- request("https://google.com")
44

5-
expect_equal(with_mocked_responses(~ resp, req_perform(req)), resp)
5+
expect_equal(with_mocked_responses(~resp, req_perform(req)), resp)
66

77
local_mocked_responses(function(req) resp)
88
expect_equal(req_perform(req), resp)

tests/testthat/test-req-perform-stream.R

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ test_that("returns empty body; sets last request & response", {
1616
})
1717

1818
test_that("HTTP errors become R errors", {
19-
req <- request_test("/status/404")
19+
req <- request_test("/status/404")
2020
expect_error(
2121
req_perform_stream(req, function(x) TRUE),
2222
class = "httr2_http_404"
@@ -29,8 +29,8 @@ test_that("HTTP errors become R errors", {
2929

3030
test_that("can override error handling", {
3131
req <- request_test("/base64/:value", value = "YWJj") %>%
32-
req_error(is_error = function(resp) TRUE)
33-
32+
req_error(is_error = function(resp) TRUE)
33+
3434
expect_error(
3535
req %>% req_perform_stream(function(x) NULL),
3636
class = "httr2_http_200"
@@ -94,7 +94,7 @@ test_that("eventually terminates even if never rounded", {
9494
test_that("req_perform_stream checks its inputs", {
9595
req <- request_test("/stream-bytes/1024")
9696
callback <- function(x) NULL
97-
97+
9898
expect_snapshot(error = TRUE, {
9999
req_perform_stream(1)
100100
req_perform_stream(req, 1)

tests/testthat/test-req-perform.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ test_that("persistent HTTP errors only get single attempt", {
5656

5757
test_that("repeated transient errors still fail", {
5858
req <- request_test("/status/:status", status = 429) %>%
59-
req_retry(max_tries = 3, backoff = ~ 0)
59+
req_retry(max_tries = 3, backoff = ~0)
6060

6161
cnd <- req_perform(req) %>%
6262
expect_error(class = "httr2_http_429") %>%

tests/testthat/test-req-retries.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ test_that("can override default backoff", {
3434
expect_equal(retry_backoff(req, 5), 26.9)
3535
expect_equal(retry_backoff(req, 10), 60)
3636

37-
req <- req_retry(req, backoff = ~ 10)
37+
req <- req_retry(req, backoff = ~10)
3838
expect_equal(retry_backoff(req, 1), 10)
3939
expect_equal(retry_backoff(req, 5), 10)
4040
expect_equal(retry_backoff(req, 10), 10)
@@ -51,7 +51,7 @@ test_that("can override default retry wait", {
5151

5252
test_that("missing retry-after uses backoff", {
5353
req <- request_test()
54-
req <- req_retry(req, backoff = ~ 10)
54+
req <- req_retry(req, backoff = ~10)
5555

5656
expect_equal(retry_after(req, response(429), 1), 10)
5757
})

tests/testthat/test-req-template.R

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,4 +59,3 @@ test_that("can use colon in uri style", {
5959
x <- "x"
6060
expect_equal(template_process("/:{x}:/"), "/:x:/")
6161
})
62-

tests/testthat/test-utils.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ test_that("replacement affects all components with name", {
1313
x <- list(a = 1, a = 2)
1414
expect_equal(modify_list(x, a = NULL), list())
1515
expect_equal(modify_list(x, a = 3), list(a = 3))
16-
expect_equal(modify_list(x, a = 3, a = 4), list(a = 3, a =4))
16+
expect_equal(modify_list(x, a = 3, a = 4), list(a = 3, a = 4))
1717
})
1818

1919
test_that("respects httr2 verbosity option", {

vignettes/articles/oauth.Rmd

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ For example, you could get a token to access the GitHub API (using the client de
163163

164164
```{r, eval = FALSE}
165165
token <- oauth_flow_auth_code(
166-
client = client,
166+
client = client,
167167
auth_url = "https://github.com/login/oauth/authorize"
168168
)
169169
```
@@ -200,21 +200,21 @@ If we make a request to this endpoint without authentication, we'll get an error
200200
```{r}
201201
#| error: true
202202
req <- request("https://api.github.com/user")
203-
req |>
203+
req |>
204204
req_perform()
205205
```
206206

207207
We can authenticate this request with `req_oauth_auth_code()`, using the same arguments as our previous call to `oauth_flow_auth_code()`:
208208

209209
```{r}
210210
#| eval: false
211-
req |>
211+
req |>
212212
req_oauth_auth_code(
213213
client = github_client(),
214214
auth_url = "https://github.com/login/oauth/authorize"
215-
) |>
216-
req_perform() |>
217-
resp_body_json() |>
215+
) |>
216+
req_perform() |>
217+
resp_body_json() |>
218218
str()
219219
```
220220

0 commit comments

Comments
 (0)