Skip to content
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
2 changes: 2 additions & 0 deletions .lintr
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
linters: linters_with_defaults() # see vignette("lintr")
encoding: "UTF-8"
2 changes: 1 addition & 1 deletion R/azkit_helpers.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
2 changes: 1 addition & 1 deletion R/get_container.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
10 changes: 5 additions & 5 deletions R/list_files.R
Original file line number Diff line number Diff line change
Expand Up @@ -36,19 +36,19 @@ 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}$"))
}

# 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 {
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-azkit_helpers.R
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
8 changes: 0 additions & 8 deletions tests/testthat/test-read_azure_files.R
Original file line number Diff line number Diff line change
Expand Up @@ -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}")
})
Expand All @@ -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)
})
) |>
Expand Down