Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix lints #834

Merged
merged 1 commit into from
Sep 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions paws.common/R/custom_s3.R
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ dns_compatible_bucket_name <- function(bucket) {
return(
grepl(domain, bucket) &&
!grepl(ip_address, bucket) &&
!grepl("..", bucket, fixed = T)
!grepl("..", bucket, fixed = TRUE)
)
}

Expand Down Expand Up @@ -499,7 +499,7 @@ handle_copy_source_param <- function(request) {
}

quote_source_header <- function(source, tags) {
result <- strsplit(source, VERSION_ID_SUFFIX, fixed = T)[[1]]
result <- strsplit(source, VERSION_ID_SUFFIX, fixed = TRUE)[[1]]
if (is.na(result[2])) {
return(tag_add(paws_url_encoder(result[1], "/"), tags))
} else {
Expand All @@ -514,7 +514,7 @@ quote_source_header_from_list <- function(source, tags) {
if (is.null(key <- source[["Key"]])) {
stopf("CopySource list is missing required parameter: Key")
}
if (grepl(VALID_S3_ARN, bucket, perl = T)) {
if (grepl(VALID_S3_ARN, bucket, perl = TRUE)) {
final <- sprintf("%s/object/%s", bucket, key)
} else {
final <- sprintf("%s/%s", bucket, key)
Expand Down
2 changes: 1 addition & 1 deletion paws.common/R/handlers_rest.R
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ rest_unmarshal_header <- function(value, type) {
rest_unmarshal_header_map <- function(values, prefix, type) {
value_names <- names(values)
value_names <- value_names[
grepl(sprintf("^%s", prefix), value_names, ignore.case = T)
grepl(sprintf("^%s", prefix), value_names, ignore.case = TRUE)
]
result <- lapply(value_names, function(name) {
rest_unmarshal_header(values[[name]], type)
Expand Down
6 changes: 3 additions & 3 deletions paws.common/R/iniutil.R
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ read_ini <- function(file_name) {
profile_nms <- gsub(
"^[ \t\r\n]+|[ \t\r\n]+$", "",
gsub("\\[|\\]", "", content[found]),
perl = T
perl = TRUE
)
profiles <- vector("list", length = length(profile_nms))
names(profiles) <- profile_nms
Expand Down Expand Up @@ -71,13 +71,13 @@ nested_ini_content <- function(sub_content, found_nested_content, sub_grp) {

position <- which(found_nested_content)
non_nest <- !(sub_grp %in% position)
profiles[non_nest] <- sub_content[sub_grp[non_nest], 2, drop = T]
profiles[non_nest] <- sub_content[sub_grp[non_nest], 2, drop = TRUE]

start <- (sub_grp + 1)
end <- c(sub_grp[-1] - 1, nrow(sub_content))
for (i in which(start <= end)) {
items <- seq.int(start[i], end[i])
profiles[[profile_nms[i]]] <- extract_ini_parameter(sub_content[items, , drop = F])
profiles[[profile_nms[i]]] <- extract_ini_parameter(sub_content[items, , drop = FALSE])
}
return(profiles)
}
2 changes: 1 addition & 1 deletion paws.common/R/net.R
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ is_compressed <- function(http_response) {
}

if (content_encoding == "gzip") {
bits_to_int <- function(x) sum(as.integer(x) * 2^(1:length(x) - 1))
bits_to_int <- function(x) sum(as.integer(x) * 2^(seq_along(x) - 1))
cmf <- http_response$body[1]
flg <- http_response$body[2]
compression_method <- bits_to_int(rawToBits(cmf)[1:4])
Expand Down
22 changes: 11 additions & 11 deletions paws.common/R/paginate.R
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ paginate <- function(Operation,
# Exit paginator if previous token matches current token
# https://github.com/smithy-lang/smithy-typescript/blob/main/packages/core/src/pagination/createPaginator.ts#L53
if (isTRUE(StopOnSameToken)) {
previous_token <- unlist(fn[[paginator$input_token]], use.names = F)
if (identical(previous_token, unlist(new_tokens, use.names = F))) {
previous_token <- unlist(fn[[paginator$input_token]], use.names = FALSE)
if (identical(previous_token, unlist(new_tokens, use.names = FALSE))) {
break
}
}
Expand Down Expand Up @@ -176,7 +176,7 @@ paginate_update_fn <- function(
pkg_name <- environmentName(environment(fn_call))

# Ensure method can be found.
if (!grepl("^paws", pkg_name, perl = T)) {
if (!grepl("^paws", pkg_name, perl = TRUE)) {
stopf(
"Unknown method: `%s`. Please check service methods and try again.",
as.character(fn)[1]
Expand Down Expand Up @@ -239,7 +239,7 @@ is_paginators <- function(fn) {
fn_body[[2]][[3]]$paginator
},
error = function(err) {
if (grepl("subscript out of bounds", err, perl = T)) {
if (grepl("subscript out of bounds", err, perl = TRUE)) {
character()
} else {
stop(err)
Expand Down Expand Up @@ -267,8 +267,8 @@ paginate_xapply <- function(
# Exit paginator if previous token matches current token
# https://github.com/smithy-lang/smithy-typescript/blob/main/packages/core/src/pagination/createPaginator.ts#L53
if (isTRUE(StopOnSameToken)) {
previous_token <- unlist(fn[[paginator$input_token]], use.names = F)
if (identical(previous_token, unlist(new_tokens, use.names = F))) {
previous_token <- unlist(fn[[paginator$input_token]], use.names = FALSE)
if (identical(previous_token, unlist(new_tokens, use.names = FALSE))) {
break
}
}
Expand Down Expand Up @@ -309,7 +309,7 @@ get_tokens <- function(resp, token, caller_env) {
},
error = function(err) {
# Return default character(0) for empty lists
if (grepl(token_error_msg, err[["message"]], perl = T)) {
if (grepl(token_error_msg, err[["message"]], perl = TRUE)) {
character(0)
} else {
stop(err)
Expand All @@ -321,9 +321,9 @@ get_tokens <- function(resp, token, caller_env) {
}

split_token <- function(token) {
token_prts <- unlist(strsplit(token, ".", fixed = T))
token_prts <- unlist(strsplit(token_prts, "[", fixed = T))
return(unlist(strsplit(token_prts, "]", fixed = T)))
token_prts <- unlist(strsplit(token, ".", fixed = TRUE))
token_prts <- unlist(strsplit(token_prts, "[", fixed = TRUE))
return(unlist(strsplit(token_prts, "]", fixed = TRUE)))
}

# This is a simple implementation of jmespath for R list: i.e.
Expand All @@ -342,7 +342,7 @@ jmespath_index <- function(token, caller_env) {
# Format character strings
token_prts[found_alpha] <- paste0('"', token_prts[found_alpha], '"')

found <- grep("-", token_prts, fixed = T)
found <- grep("-", token_prts, fixed = TRUE)
if (length(found) > 0) {
# Path.To[-1].Token
position <- found - 1
Expand Down
2 changes: 1 addition & 1 deletion paws.common/R/queryutil.R
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ query_parse_map <- function(values, value, prefix, tag, is_ec2 = FALSE) {
# will be one R list element with no name, which we shouldn't process.
map_entries <- !is.null(names(value))
if (map_entries) {
value[1:length(value)] <- value[names(value)]
value[seq_along(value)] <- value[names(value)]

for (i in seq_along(value)) {
map_key <- names(value)[i]
Expand Down
2 changes: 1 addition & 1 deletion paws.common/R/util.R
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ check_dns_name <- function(bucket_name) {
if (n < 3 || n > 63) {
return(FALSE)
}
m <- regexpr(LABEL_RE, bucket_name, perl = T)
m <- regexpr(LABEL_RE, bucket_name, perl = TRUE)
match <- regmatches(bucket_name, m)
if (identical(match, character(0)) || nchar(match) != n) {
return(FALSE)
Expand Down
2 changes: 1 addition & 1 deletion paws.common/tests/testthat/test_custom_s3.R
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ test_that("update url endpoint with new endpoint", {
test_that("update url endpoint with new endpoint without new scheme", {
org_ep <- "https://s3.eu-east-2.amazonaws.com"
new_ep <- "sftp://s3.amazonaws.com"
actual <- set_request_url(org_ep, new_ep, F)
actual <- set_request_url(org_ep, new_ep, FALSE)
expect_equal(actual, "https://s3.amazonaws.com")
})

Expand Down
6 changes: 3 additions & 3 deletions paws.common/tests/testthat/test_escape.R
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ test_that("check if non-ascci characters are correctly encoded", {
test_that("check if encoded url is correctly decoded", {
string <- "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._~`!@#$%^&*()=+[{]}\\|;:'\",<>/? "

url <- paste0(sample(strsplit(string, "")[[1]], 1e4, replace = T), collapse = "")
url <- paste0(sample(strsplit(string, "")[[1]], 1e4, replace = TRUE), collapse = "")
url_encode <- paws_url_encoder(url)
actual <- unescape(url_encode)

Expand All @@ -41,7 +41,7 @@ test_that("check if encoded url is correctly decoded", {
test_that("check if non-encoded url is correctly decoded", {
string <- "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._~"

url <- paste(sample(strsplit(string, "")[[1]], 1e4, replace = T), collapse = "")
url <- paste(sample(strsplit(string, "")[[1]], 1e4, replace = TRUE), collapse = "")
url_encode <- paws_url_encoder(url)
actual <- unescape(url_encode)

Expand All @@ -51,6 +51,6 @@ test_that("check if non-encoded url is correctly decoded", {

test_that("check if json string is converted correctly", {
expect <- "\"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ\\u0001\\u0002\\u0003\\u0004\\u0005\\u0006\\u0007\\b\\t\\n\\u000b\\f\\r\\u000e\\u000f\\u0010\\u0011\\u0012\\u0013\\u0014\\u0015\\u0016\\u0017\\u0018\\u0019\\u001a\\u001b\\u001c\\u001d\\u001e\\u001f\\\\\\\"\\b\\f\\r\\t\\n\""
string <- paste0(c(letters, LETTERS, intToUtf8(1:31, multiple = T), "\\", '"', "\b", "\f", "\r", "\t", "\n"), collapse = "")
string <- paste0(c(letters, LETTERS, intToUtf8(1:31, multiple = TRUE), "\\", '"', "\b", "\f", "\r", "\t", "\n"), collapse = "")
expect_equal(json_convert_string(string), expect)
})
4 changes: 2 additions & 2 deletions paws.common/tests/testthat/test_handlers.R
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ test_that("setting and adding handlers", {

g <- function(x) 2
handlers$validate <- handlers_add_back(handlers$validate, g)
expect_equal(length(handlers$validate$list), 2)
expect_length(handlers$validate$list, 2)
expect_equal(handlers$validate$list[[1]]$fn, f)
expect_equal(handlers$validate$list[[2]]$fn, g)

h <- function(x) 3
handlers$validate <- handlers_add_front(handlers$validate, h)
expect_equal(length(handlers$validate$list), 3)
expect_length(handlers$validate$list, 3)
expect_equal(handlers$validate$list[[1]]$fn, h)
expect_equal(handlers$validate$list[[2]]$fn, f)
expect_equal(handlers$validate$list[[3]]$fn, g)
Expand Down
8 changes: 4 additions & 4 deletions paws.common/tests/testthat/test_handlers_core.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ test_that("validate_endpoint_handler no endpoint", {
svc$handlers$validate <- HandlerList(validate_endpoint_handler)
req <- new_request(svc, Operation(name = "Operation"), NULL, NULL)
ret <- build(req)
expect_true(!is.null(ret$error))
expect_false(is.null(ret$error))
})

test_that("validate_endpoint_handler no region", {
svc <- Client()
svc$handlers$validate <- HandlerList(validate_endpoint_handler)
req <- new_request(svc, Operation(name = "Operation"), NULL, NULL)
ret <- build(req)
expect_true(!is.null(ret$error))
expect_false(is.null(ret$error))
})

test_that("build_content_length_handler", {
Expand Down Expand Up @@ -54,12 +54,12 @@ test_that("validate_response_handler", {
r <- Request()
r$http_response <- HttpResponse(status_code = 400)
out <- validate_response_handler(r)
expect_true(!is.null(out$error))
expect_false(is.null(out$error))

r <- Request()
r$http_response <- HttpResponse(status_code = "500")
out <- validate_response_handler(r)
expect_true(!is.null(out$error))
expect_false(is.null(out$error))
})

expect_user_agent <- function(request) {
Expand Down
4 changes: 2 additions & 2 deletions paws.common/tests/testthat/test_handlers_ec2query.R
Original file line number Diff line number Diff line change
Expand Up @@ -244,12 +244,12 @@ test_that("unmarshal scalar members", {
out <- req$data
expect_equal(out$Char, "a")
expect_equal(out$Double, 1.3)
expect_equal(out$FalseBool, FALSE)
expect_false(out$FalseBool)
expect_equal(out$Float, 1.2)
expect_equal(out$Long, 200L)
expect_equal(out$Num, 123L)
expect_equal(out$Str, "myname")
expect_equal(out$TrueBool, TRUE)
expect_true(out$TrueBool)
})

op_output2 <- Structure(
Expand Down
22 changes: 11 additions & 11 deletions paws.common/tests/testthat/test_handlers_jsonrpc.R
Original file line number Diff line number Diff line change
Expand Up @@ -481,12 +481,12 @@ test_that("unmarshal scalar members", {
out <- req$data
expect_equal(out$Char, "a")
expect_equal(out$Double, 1.3)
expect_equal(out$FalseBool, FALSE)
expect_false(out$FalseBool)
expect_equal(out$Float, 1.2)
expect_equal(out$Long, 200L)
expect_equal(out$Num, 123L)
expect_equal(out$Str, "myname")
expect_equal(out$TrueBool, TRUE)
expect_true(out$TrueBool)
})

op_output2 <- Structure(
Expand Down Expand Up @@ -556,14 +556,14 @@ test_that("unmarshal list", {
out <- req$data
expect_equal(out$ListMember[1], "a")
expect_equal(out$ListMember[2], NA_character_)
expect_equal(out$ListMemberMap[[1]], NULL)
expect_equal(out$ListMemberMap[[2]], NULL)
expect_equal(out$ListMemberMap[[3]], NULL)
expect_equal(out$ListMemberMap[[4]], NULL)
expect_equal(out$ListMemberStruct[[1]], NULL)
expect_equal(out$ListMemberStruct[[2]], NULL)
expect_equal(out$ListMemberStruct[[3]], NULL)
expect_equal(out$ListMemberStruct[[4]], NULL)
expect_null(out$ListMemberMap[[1]])
expect_null(out$ListMemberMap[[2]])
expect_null(out$ListMemberMap[[3]])
expect_null(out$ListMemberMap[[4]])
expect_null(out$ListMemberStruct[[1]])
expect_null(out$ListMemberStruct[[2]])
expect_null(out$ListMemberStruct[[3]])
expect_null(out$ListMemberStruct[[4]])
})

op_output5 <- Structure(
Expand Down Expand Up @@ -596,7 +596,7 @@ test_that("unmarshal ignores extra data", {
)
req <- unmarshal(req)
out <- req$data
expect_equal(names(out), "StrType")
expect_named(out, "StrType")
expect_equal(out$StrType, character(0), ignore_attr = TRUE)
})

Expand Down
4 changes: 2 additions & 2 deletions paws.common/tests/testthat/test_handlers_query.R
Original file line number Diff line number Diff line change
Expand Up @@ -432,12 +432,12 @@ test_that("unmarshal scalar members", {
out <- req$data
expect_equal(out$Char, "a")
expect_equal(out$Double, 1.3)
expect_equal(out$FalseBool, FALSE)
expect_false(out$FalseBool)
expect_equal(out$Float, 1.2)
expect_equal(out$Long, 200L)
expect_equal(out$Num, 123L)
expect_equal(out$Str, "myname")
expect_equal(out$TrueBool, TRUE)
expect_true(out$TrueBool)
})

test_that("unmarshal scalar members", {
Expand Down
4 changes: 2 additions & 2 deletions paws.common/tests/testthat/test_handlers_restxml.R
Original file line number Diff line number Diff line change
Expand Up @@ -574,12 +574,12 @@ test_that("unmarshal scalar members", {
out <- req$data
expect_equal(out$Char, "a")
expect_equal(out$Double, 1.3)
expect_equal(out$FalseBool, FALSE)
expect_false(out$FalseBool)
expect_equal(out$Float, 1.2)
expect_equal(out$Long, 200L)
expect_equal(out$Num, 123L)
expect_equal(out$Str, "myname")
expect_equal(out$TrueBool, TRUE)
expect_true(out$TrueBool)
})

op_output2 <- Structure(
Expand Down
4 changes: 2 additions & 2 deletions paws.common/tests/testthat/test_iniutil.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ test_that("Ignores lines starting with # and ;", {
# clear down cache
paws_reset_cache()
content <- read_ini("data_ini")
expect_true(!("ignore1" %in% names(content)))
expect_true(!("ignore2" %in% names(content)))
expect_false(("ignore1" %in% names(content)))
expect_false(("ignore2" %in% names(content)))
})

test_that("Reads in profile with space in name", {
Expand Down
2 changes: 1 addition & 1 deletion paws.common/tests/testthat/test_net.R
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ test_that("don't decompress the body when already decompressed", {
if (resp$status_code == 200) {
expect_equal(resp$status_code, 200)
expect_error(body <- jsonlite::fromJSON(rawToChar(resp$body)), NA)
expect_equal(body$gzipped, TRUE)
expect_true(body$gzipped)
}
})

Expand Down
2 changes: 1 addition & 1 deletion paws.common/tests/testthat/test_retry.R
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ test_that("check exponential back off", {

mockery::stub(exp_back_off, "Sys.sleep", mock_sys_sleep)
exp_back_off(error, 1, 2)
expect_true(mock_arg(mock_sys_sleep)[[1]] < 20)
expect_lt(mock_arg(mock_sys_sleep)[[1]], 20)
})

test_that("check exponential back off iteration greater 20", {
Expand Down
Loading
Loading