diff --git a/.lintr b/.lintr new file mode 100644 index 0000000..b08f4e1 --- /dev/null +++ b/.lintr @@ -0,0 +1,2 @@ +linters: linters_with_defaults() # see vignette("lintr") +encoding: "UTF-8" diff --git a/R/azkit_helpers.R b/R/azkit_helpers.R index ade1653..8003217 100644 --- a/R/azkit_helpers.R +++ b/R/azkit_helpers.R @@ -109,7 +109,7 @@ check_container_class <- function(container) { if (inherits(container, "blob_container")) { container } else { - ccc <- "check_container_class" + ccc <- "check_container_class" # nolint cc <- rlang::caller_call() cli::cli_abort("{.fn {ccc}}: This is not a valid blob container", call = cc) } diff --git a/R/get_container.R b/R/get_container.R index a255e85..f090401 100644 --- a/R/get_container.R +++ b/R/get_container.R @@ -31,7 +31,7 @@ get_container <- function(container_name = NULL, ...) { list_container_names <- function(token = NULL, ...) { token <- token %||% get_auth_token(...) endpoint <- get_default_endpoint(token) - lcn <- "list_container_names" + lcn <- "list_container_names" # nolint container_list <- AzureStor::list_blob_containers(endpoint) |> rlang::try_fetch(error = \(e) cli::cli_abort("Error in {.fn {lcn}}: {e}")) stopifnot("no containers found" = length(container_list) >= 1L) diff --git a/R/list_files.R b/R/list_files.R index bbb889d..a33ed39 100644 --- a/R/list_files.R +++ b/R/list_files.R @@ -36,7 +36,7 @@ list_files <- function(container, path = "", ext = "", recursive = TRUE) { tbl <- AzureStor::list_blobs(container, path, recursive = recursive) if (nrow(tbl) > 0) { - ext_rx <- if (nzchar(ext)) sub("^\\.+", "", ext) else ".*" + ext_rx <- if (nzchar(ext)) sub("^\\.+", "", ext) else ".*" # nolint tbl <- tbl |> dplyr::filter(!.data[["isdir"]] & gregg(.data[["name"]], "\\.{ext_rx}$")) } @@ -44,11 +44,11 @@ list_files <- function(container, path = "", ext = "", recursive = TRUE) { # A zero-row tbl can result if `path` is initially empty, or via the filter # step above. We handle this the same way, no matter which route led here. if (nrow(tbl) == 0) { + fix_path <- \(p) sub("^/+$", "", sub("^([^/])(.*)", "/\\1\\2", p)) # nolint + ext <- if (nzchar(ext)) paste0(" ", ext) + msg <- "No{ext} files found in {.val [{container$name}]:{fix_path(path)}}" if (rlang::is_interactive()) { - ext <- if (nzchar(ext)) paste0(" ", ext) - fix_path <- \(path) sub("^/+$", "", sub("^([^/])(.*)", "/\\1\\2", path)) - "No{ext} files found in {.val [{container[['name']]}]{fix_path(path)}}" |> - cli::cli_alert_info() + cli::cli_alert_info(msg) } invisible(character(0)) } else { diff --git a/tests/testthat/test-azkit_helpers.R b/tests/testthat/test-azkit_helpers.R index 9c34bd5..e336d89 100644 --- a/tests/testthat/test-azkit_helpers.R +++ b/tests/testthat/test-azkit_helpers.R @@ -15,7 +15,7 @@ test_that("I understand how rlang::abort works", { var <- "test" message <- "{.var {var}} error" # will only succeed if devtools::load_all() has been run: - # expect_error(rlang::abort(message), "`test` error") + # expect_error(rlang::abort(message), "`test` error") # nolint expect_error(rlang::abort(message), class = "rlang_error") rlang::local_use_cli(inline = TRUE) expect_error(rlang::abort(message), "`test` error", class = "rlang_error") diff --git a/tests/testthat/test-read_azure_files.R b/tests/testthat/test-read_azure_files.R index c4e57bb..06535c8 100644 --- a/tests/testthat/test-read_azure_files.R +++ b/tests/testthat/test-read_azure_files.R @@ -189,10 +189,6 @@ test_that("dirname and basename logic works", { filepath_out <- AzureStor::list_blobs(res, path, recursive = FALSE) |> dplyr::filter( !dplyr::if_any("isdir") & - # Don't include `filepath` in the first regex here, because we want to - # filter to `file_ext` explicitly, as well as also allow for - # `filepath`to include its file extension if that suits the user's - # approach. dplyr::if_any("name", \(x) { gregg(x, "\\.{file_ext}$") & gregg(x, "^{filepath}") }) @@ -219,10 +215,6 @@ test_that("tdd of check_blob_exists", { dplyr::filter( !dplyr::if_any("isdir") & dplyr::if_any("name", \(x) { - # Don't include `file` in the regex here, because we want to - # filter to `file_ext` explicitly, as well as also allow for - # `file` to include its file extension if that suits the user's - # approach. grepl(glue::glue("\\.{file_ext}$"), x) & grepl(file, x) }) ) |>