From 2e99921dc9b84c847f478b5c15b9fda44c2446b6 Mon Sep 17 00:00:00 2001 From: Etienne Bacher <52219252+etiennebacher@users.noreply.github.com> Date: Thu, 22 Aug 2024 10:48:06 +0200 Subject: [PATCH] Fix some lints --- R/data.R | 2 +- R/proj-desc.R | 2 +- R/use_standalone.R | 2 +- R/utils-git.R | 2 +- R/utils-github.R | 2 +- tests/manual/manual-use-github.R | 2 +- tests/testthat/test-proj.R | 4 ++-- tests/testthat/test-utils-github.R | 2 +- 8 files changed, 9 insertions(+), 9 deletions(-) diff --git a/R/data.R b/R/data.R index e19cb04b7..5003c0c77 100644 --- a/R/data.R +++ b/R/data.R @@ -92,7 +92,7 @@ get_objs_from_dots <- function(.dots) { } is_name <- vapply(.dots, is.symbol, logical(1)) - if (any(!is_name)) { + if (!all(is_name)) { ui_abort("Can only save existing named objects.") } diff --git a/R/proj-desc.R b/R/proj-desc.R index d2e110a7e..aa962b5c4 100644 --- a/R/proj-desc.R +++ b/R/proj-desc.R @@ -41,7 +41,7 @@ proj_desc_field_update <- function(key, value, overwrite = TRUE, append = FALSE) return(invisible()) } - if (!overwrite && length(old > 0) && any(old != "")) { + if (!overwrite && length(old) > 0 && any(old != "")) { ui_abort(" {.field {key}} has a different value in DESCRIPTION. Use {.code overwrite = TRUE} to overwrite.") diff --git a/R/use_standalone.R b/R/use_standalone.R index e23d1cba7..11ca47e12 100644 --- a/R/use_standalone.R +++ b/R/use_standalone.R @@ -247,7 +247,7 @@ as_version_info_row <- function(field, error_call = caller_env()) { ver <- strsplit(ver, " ")[[1]] - if (!is_character(ver, n = 2) || any(is.na(ver)) || !all(nzchar(ver))) { + if (!is_character(ver, n = 2) || anyNA(ver) || !all(nzchar(ver))) { cli::cli_abort( c( "Can't parse version `{field}` in `imports:` field.", diff --git a/R/utils-git.R b/R/utils-git.R index 810988d45..9a3a57cb5 100644 --- a/R/utils-git.R +++ b/R/utils-git.R @@ -83,7 +83,7 @@ git_user_get <- function(where = c("de_facto", "local", "global")) { # translate from "usethis" terminology to "git" terminology where_from_scope <- function(scope = c("user", "project")) { - scope = match.arg(scope) + scope <- match.arg(scope) where_scope <- c(user = "global", project = "de_facto") diff --git a/R/utils-github.R b/R/utils-github.R index 66fca74bd..abba6d408 100644 --- a/R/utils-github.R +++ b/R/utils-github.R @@ -193,7 +193,7 @@ github_remotes <- function(these = c("origin", "upstream"), # 1. Did we call the GitHub API? Means we know `is_fork` and the parent repo. # 2. If so, did we call it with auth? Means we know if we can push. grl$github_got <- map_lgl(repo_info, ~ length(.x) > 0) - if (isTRUE(github_get) && any(!grl$github_got)) { + if (isTRUE(github_get) && !all(grl$github_got)) { oops <- which(!grl$github_got) oops_remotes <- grl$remote[oops] oops_hosts <- unique(grl$host[oops]) diff --git a/tests/manual/manual-use-github.R b/tests/manual/manual-use-github.R index aefde5e88..c98f02860 100644 --- a/tests/manual/manual-use-github.R +++ b/tests/manual/manual-use-github.R @@ -59,7 +59,7 @@ expect_match(desc::desc_get_field("BugReports"), BugReports) # remove the GitHub links desc::desc_del(c("BugReports", "URL")) -expect_true(all(!desc::desc_has_fields(c("BugReports", "URL")))) +expect_true(!any(desc::desc_has_fields(c("BugReports", "URL")))) # restore the GitHub links # should see a warning that `host` is deprecated and ignored diff --git a/tests/testthat/test-proj.R b/tests/testthat/test-proj.R index c2bf4a20c..826e578b1 100644 --- a/tests/testthat/test-proj.R +++ b/tests/testthat/test-proj.R @@ -148,12 +148,12 @@ test_that("with_project() runs code in temp proj, restores (lack of) proj", { ) proj_set_(NULL) - expect_identical(proj_get_(), NULL) + expect_null(proj_get_()) res <- with_project(path = temp_proj, proj_get_()) expect_identical(res, temp_proj) - expect_identical(proj_get_(), NULL) + expect_null(proj_get_()) }) test_that("with_project() runs code in temp proj, restores original proj", { diff --git a/tests/testthat/test-utils-github.R b/tests/testthat/test-utils-github.R index e37314336..02131969a 100644 --- a/tests/testthat/test-utils-github.R +++ b/tests/testthat/test-utils-github.R @@ -11,7 +11,7 @@ test_that("parse_github_remotes() works, on named list or named character", { bitbucket2 = "git@bitbucket.org:OWNER/REPO.git" ) parsed <- parse_github_remotes(urls) - expect_equal(parsed$name, names(urls)) + expect_named(urls, parsed$name) expect_equal(unique(parsed$repo_owner), "OWNER") expect_equal( parsed$host,