From aeb1e6967db97af450a07cd256a9f059a4ecb4f5 Mon Sep 17 00:00:00 2001 From: Hugo Gruson Date: Mon, 20 Jul 2026 11:11:28 +0200 Subject: [PATCH 1/5] Use startsWith() where appropriate --- R/compression.R | 2 +- R/remote_to_local.R | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/R/compression.R b/R/compression.R index de3af91..f7ef7f4 100644 --- a/R/compression.R +++ b/R/compression.R @@ -87,7 +87,7 @@ parse_archive <- function(file, which, file_type, ...) { extract_func(file, files = file_list[which], exdir = d) return(file.path(d, file_list[which])) } - if (substring(which, 1, 1) != "^") { + if (!startsWith(which, "^")) { which2 <- paste0("^", which) } extract_func(file, files = file_list[grep(which2, file_list)[1]], exdir = d) diff --git a/R/remote_to_local.R b/R/remote_to_local.R index edfbf8e..945c8d4 100644 --- a/R/remote_to_local.R +++ b/R/remote_to_local.R @@ -29,7 +29,7 @@ remote_to_local <- function(file, format) { ## try to extract format from headers: read #403 about whether this code is doing anything h1 <- curl::parse_headers(u$headers) ## check `Content-Disposition` header - if (!any(grepl("^Content-Disposition", h1))) { + if (!any(startsWith(h1, "Content-Disposition"))) { stop("Unrecognized file format. Try specifying with the format argument.") } h <- h1[grep("filename", h1, fixed = TRUE)] From 2c3034769d2d8712d2ff587d37ff6ed7774ea738 Mon Sep 17 00:00:00 2001 From: Hugo Gruson Date: Mon, 20 Jul 2026 11:11:44 +0200 Subject: [PATCH 2/5] Use seq_along() instead of seq_len(length()) --- R/set_class.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/set_class.R b/R/set_class.R index 2f00a6d..349d3ea 100644 --- a/R/set_class.R +++ b/R/set_class.R @@ -46,7 +46,7 @@ set_class <- function(x, class = NULL) { return(out) } if (!length(rownames(out))) { - rownames(out) <- as.character(seq_len(length(out[, 1L, drop = TRUE]))) + rownames(out) <- as.character(seq_along(out[, 1L, drop = TRUE])) } return(out) } From 27c9296ab2deb06f250a59a5c5fecab20e94ef98 Mon Sep 17 00:00:00 2001 From: Hugo Gruson Date: Mon, 20 Jul 2026 11:11:53 +0200 Subject: [PATCH 3/5] Mark regex as fixed --- R/suggestions.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/suggestions.R b/R/suggestions.R index 1aba049..a8fad28 100644 --- a/R/suggestions.R +++ b/R/suggestions.R @@ -26,7 +26,7 @@ uninstalled_formats <- function() { show_unsupported_formats <- function() { ## default_formats <- sort(unique(rio_formats$format[rio_formats$type == "import"])) suggested_formats <- rio_formats[rio_formats$type == "suggest",] - suggested_formats$pkg <- vapply(strsplit(suggested_formats$import_function, "::"), FUN = `[`, FUN.VALUE = character(1), 1) + suggested_formats$pkg <- vapply(strsplit(suggested_formats$import_function, "::", fixed = TRUE), FUN = `[`, FUN.VALUE = character(1), 1) missing_pkgs <- uninstalled_formats() suggested_formats$installed <- vapply(suggested_formats$pkg, function(x) x %in% missing_pkgs, logical(1), USE.NAMES = FALSE) unsupported_formats <- suggested_formats[suggested_formats$installed,] From 638eb8769a4b9d21b09b9d0cf8c42376076ec7a6 Mon Sep 17 00:00:00 2001 From: Hugo Gruson Date: Mon, 20 Jul 2026 11:12:06 +0200 Subject: [PATCH 4/5] Use anyNA() instead of any(is.na()) --- R/utils.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/utils.R b/R/utils.R index 81d38c8..3faa660 100644 --- a/R/utils.R +++ b/R/utils.R @@ -99,7 +99,7 @@ escape_xml <- function(x, replacement = c("&", """, "<", ">", "&a if (isFALSE(length(file) == 1) && single_only) { stop("Invalid `file` argument: `file` must be single", call. = FALSE) } - if (any(is.na(file))) { + if (anyNA(file)) { stop("Invalid `file` argument: `file` must not be NA", call. = FALSE) } invisible(NULL) From f1415faf1e7def5c95750c98dcf23e5ee5f753f7 Mon Sep 17 00:00:00 2001 From: Hugo Gruson Date: Mon, 20 Jul 2026 11:18:23 +0200 Subject: [PATCH 5/5] Avoid isTRUE() / isFALSE on functions that can only return logicals --- R/compression.R | 4 ++-- R/export_methods.R | 2 +- R/import_methods.R | 2 +- R/utils.R | 8 ++++---- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/R/compression.R b/R/compression.R index f7ef7f4..bb4230b 100644 --- a/R/compression.R +++ b/R/compression.R @@ -137,8 +137,8 @@ parse_archive <- function(file, which, file_type, ...) { .get_compressed_format <- function(cfile, file, file_type, format) { if (file_type %in% c("gzip", "bzip2")) { - return(ifelse(isFALSE(missing(format)), tolower(format), get_info(find_compress(cfile)$file)$input)) + return(ifelse(!missing(format), tolower(format), get_info(find_compress(cfile)$file)$input)) } ## zip or tar formats, use the decompressed file path - return(ifelse(isFALSE(missing(format)), tolower(format), get_info(file)$input)) + return(ifelse(!missing(format), tolower(format), get_info(file)$input)) } diff --git a/R/export_methods.R b/R/export_methods.R index d6a8be8..2b18b07 100644 --- a/R/export_methods.R +++ b/R/export_methods.R @@ -115,7 +115,7 @@ export_delim <- function(file, x, fwrite = lifecycle::deprecated(), sep = "\t", #' @export .export.rio_rdata <- function(file, x, ...) { - if (isFALSE(is.data.frame(x)) && isFALSE(is.list(x)) && isFALSE(is.environment(x)) && isFALSE(is.character(x))) { + if (!(is.data.frame(x) || is.list(x) || is.environment(x) || is.character(x))) { stop("'x' must be a data.frame, list, or environment") } if (is.data.frame(x)) { diff --git a/R/import_methods.R b/R/import_methods.R index a11e992..8e7009e 100644 --- a/R/import_methods.R +++ b/R/import_methods.R @@ -98,7 +98,7 @@ import_delim <- function(file, which = 1, sep = "auto", header = "auto", strings } .fix_col_types <- function(col_types, widths) { - if (isFALSE(is.numeric(widths))) { + if (!is.numeric(widths)) { return(col_types) } col_types <- rep("?", length(widths)) diff --git a/R/utils.R b/R/utils.R index 3faa660..50f2a60 100644 --- a/R/utils.R +++ b/R/utils.R @@ -25,7 +25,7 @@ get_info <- function(file) { if (tolower(file) == "clipboard") { return(.query_format(input = "clipboard", file = "clipboard")) } - if (isFALSE(R.utils::isUrl(file))) { + if (!R.utils::isUrl(file)) { ext <- tolower(tools::file_ext(file)) } else { parsed <- strsplit(strsplit(file, "?", fixed = TRUE)[[1]][1], "/", fixed = TRUE)[[1]] @@ -90,13 +90,13 @@ escape_xml <- function(x, replacement = c("&", """, "<", ">", "&a .check_file <- function(file, single_only = TRUE) { ## check the `file` argument - if (isTRUE(missing(file))) { ## for the case of export(iris, format = "csv") + if (missing(file)) { ## for the case of export(iris, format = "csv") return(invisible(NULL)) } - if (isFALSE(inherits(file, "character"))) { + if (!inherits(file, "character")) { stop("Invalid `file` argument: must be character", call. = FALSE) } - if (isFALSE(length(file) == 1) && single_only) { + if (length(file) != 1 && single_only) { stop("Invalid `file` argument: `file` must be single", call. = FALSE) } if (anyNA(file)) {