Last active
October 20, 2024 16:51
-
-
Save EmilHvitfeldt/13530c687cbd7975e4ac51fb1f9ddc49 to your computer and use it in GitHub Desktop.
find untested cli code in R package
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(tidyverse) | |
# https://github.com/r-lib/covr/issues/482 | |
res_tbl <- devtools::test_coverage() |> | |
purrr::map(~tibble( | |
value = if_else(is.null(.x$value), NA, .x$value), | |
code = as.character(.x$srcref) | |
)) |> | |
purrr::list_rbind(names_to = "file") | |
# Tibble output | |
res_tbl |> | |
filter(value == 0, str_detect(code, "(cli_abort|cli_warn|cli_inform)")) |> | |
arrange(file) | |
# Cleaned up version | |
res_tbl |> | |
filter(value == 0, str_detect(code, "(cli_abort|cli_warn|cli_inform)")) |> | |
arrange(file) |> | |
mutate(file = str_extract(file, ".*?:.*?:")) |> | |
mutate(file = str_remove(file, ":$")) |> | |
pull(file) |> | |
cat(sep = "\n") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment