From 5aaa785513081ca1f8bf82eb10c9afd7ab97956f Mon Sep 17 00:00:00 2001 From: Hugo Gruson Date: Fri, 12 Jun 2026 16:09:24 +0200 Subject: [PATCH 1/4] Test package installed with requireNamespace() --- R/install.R | 2 +- R/utilities.R | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/R/install.R b/R/install.R index e681b9d5..e58e4688 100644 --- a/R/install.R +++ b/R/install.R @@ -99,7 +99,7 @@ .install_github_load_remotes <- function(pkgs, lib.loc = NULL) { - if (!"remotes" %in% rownames(installed.packages(lib.loc))) { + if (!requireNamespace("remotes", lib.loc = lib.loc, quietly = TRUE)) { if (is.null(lib.loc)) lib.loc <- .libPaths() .stop( diff --git a/R/utilities.R b/R/utilities.R index 68071942..2e27c64a 100644 --- a/R/utilities.R +++ b/R/utilities.R @@ -129,6 +129,6 @@ isRelease <- .skip_if_BiocVersion_not_available <- function() { - if (!"BiocVersion" %in% rownames(installed.packages())) + if (!requireNamespace("BiocVersion", quietly = TRUE)) testthat::skip("BiocVersion not installed") } From 8e913db7771a1b70eba155f9c3983831db1a12dc Mon Sep 17 00:00:00 2001 From: Hugo Gruson Date: Fri, 12 Jun 2026 16:10:37 +0200 Subject: [PATCH 2/4] Mark some regexes as fixed --- R/inet.R | 5 +++-- R/version.R | 6 +++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/R/inet.R b/R/inet.R index f5b6f887..d611d402 100644 --- a/R/inet.R +++ b/R/inet.R @@ -91,11 +91,12 @@ NULL }) }, warning = function(w) { msg <- conditionMessage(w) - if (grepl("not available", msg)) { + if (grepl("not available", msg, fixed = TRUE)) { msg <- gsub( "this version of R", paste0("Bioconductor version ", "'", version(), "'"), - msg + msg, + fixed = TRUE ) w <- simpleWarning(msg, conditionCall(w)) } diff --git a/R/version.R b/R/version.R index 77371144..fc25ef7f 100644 --- a/R/version.R +++ b/R/version.R @@ -108,7 +108,7 @@ format.version_sentinel <- txt <- tryCatch(.inet_readLines(config), error = identity) if (inherits(txt, "error")) { if (startsWith(config, "https://")) - config <- sub("https", "http", config) + config <- sub("https", "http", config, fixed = TRUE) else if (!startsWith(config, "http")) config <- paste0("file://", config) txt <- tryCatch(.inet_readLines(config), error = identity) @@ -125,7 +125,7 @@ format.version_sentinel <- return(setNames(character(), character())) end <- ifelse(length(grps) < start + 1L, length(txt), grps[start + 1] - 1L) map <- txt[seq(grps[start] + 1, end)] - map <- trimws(gsub("\"", "", sub(" #.*", "", map))) + map <- trimws(gsub("\"", "", sub(" #.*", "", map), fixed = TRUE)) pattern <- "(.*): (.*)" key <- sub(pattern, "\\1", map) @@ -263,7 +263,7 @@ format.version_sentinel <- sprintf( "Bioconductor version %s (BiocManager %s), %s", bioc_version, packageVersion("BiocManager"), - sub(" version", "", R.version.string) + sub(" version", "", R.version.string, fixed = TRUE) ) } From 6c0aa3ab589ec125fd1cb1e816c1278f93ecbcab Mon Sep 17 00:00:00 2001 From: Hugo Gruson Date: Fri, 12 Jun 2026 16:11:08 +0200 Subject: [PATCH 3/4] Use nzchar() instead of nchar() --- R/version.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/version.R b/R/version.R index fc25ef7f..8b297e3f 100644 --- a/R/version.R +++ b/R/version.R @@ -215,7 +215,7 @@ format.version_sentinel <- if (!.version_validity_online_check()) .version_map_get_offline() else { - if (is.null(config) || !nchar(config)) + if (is.null(config) || !nzchar(config)) config <- "https://bioconductor.org/config.yaml" .version_map_get_online(config) } From a1fcc45189dc7de7e20b9634ca832b330327c36d Mon Sep 17 00:00:00 2001 From: Hugo Gruson Date: Fri, 12 Jun 2026 16:17:25 +0200 Subject: [PATCH 4/4] Simplify if/else chaining --- R/install.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/install.R b/R/install.R index e58e4688..2f8b9fb7 100644 --- a/R/install.R +++ b/R/install.R @@ -146,7 +146,7 @@ function(pkgs, lib, lib.loc, repos, update, ask, force, ...) { doing <- .install_filter_github_repos(pkgs) - ask <- if (!update) "never" else if (update && !ask) "always" else "default" + ask <- if (!update) "never" else if (!ask) "always" else "default" oopts <- options(repos = repos) # required by remotes:: on.exit(options(oopts))