riskassessment
riskassessment copied to clipboard
Ensure Code Coverage is > 80%
Related to #295 @Robert-Krajcik or @AARON-CLARK, to run code that produces function-level tracking of composed unit tests and paste here.
Here are some modules that currently do not have a unit test associated with them:
library(dplyr)
library(stringr)
library(purrr)
r_files <- list.files(file.path(getwd(), "R"), pattern="*.R")
t_files <- list.files(file.path(getwd(), "tests/testthat"), pattern = "*.R")
test_files <- map_chr(t_files, ~substr(.x, 6, nchar(.x))) # remove test- prefix
mod_files <- r_files[str_detect(r_files, "mod_") & str_detect(r_files, "_utils", TRUE)] %>%
str_replace_all("_", "-") %>% str_replace_all(., "mod-", "")
setdiff(mod_files, test_files) %>% tools::file_path_sans_ext()
[1] "assessmentInfo" "code-explorer" "decision-automation" "metric-rule"
[5] "metricBox" "metricGrid" "pkg-explorer" "user-roles"
[9] "viewComments"
Here are some exported objects that do not currently have tests.
all_funcs <- getNamespaceExports("riskassessment")
all_funcx <- all_funcs[!str_detect(all_funcs, stringr::regex("^[t|l]\\_"))]
t_filesx <- test_files[!str_detect(test_files, stringr::regex("^[t|l]\\-"))] %>%
str_replace_all("-", "_") %>%
str_replace_all("_R_", "_r_") %>%
str_replace_all(stringr::regex("\\.R$"), "")
setdiff(all_funcx, t_filesx)
[1] "run_app" "app_theme" "build_comm_plotly" "showComments"
[5] "initialize_raa"
Output from {covr}
.
covr::package_coverage()
riskassessment Coverage: 74.52%
R/mod_code_explorer_utils.R: 0.00%
R/mod_pkg_explorer_utils.R: 0.00%
R/mod_packageDependencies.R: 24.07%
R/mod_code_explorer.R: 26.55%
R/mod_user_roles.R: 33.07%
R/mod_pkg_explorer.R: 46.00%
R/utils_startup.R: 61.31%
R/mod_decision_automation_utils.R: 64.71%
R/utils_config_db.R: 66.94%
R/run_app.R: 67.44%
R/utils_build_cards.R: 69.42%
R/mod_downloadHandler.R: 71.13%
R/app_server.R: 79.10%
R/mod_decision_automation.R: 79.95%
R/mod_reportPreview.R: 80.44%
R/mod_uploadPackage.R: 81.40%
R/utils_insert_db.R: 81.61%
R/mod_assessmentInfo.R: 84.69%
R/utils_get_db.R: 87.50%
R/mod_databaseView.R: 91.05%
R/mod_communityMetrics.R: 94.64%
R/mod_metric_rule.R: 95.97%
R/mod_reweightView.R: 96.14%
R/mod_sidebar.R: 96.51%
R/utils.R: 96.83%
R/mod_addComment.R: 97.50%
R/mod_introJS.R: 97.50%
R/mod_maintenanceMetrics.R: 97.50%
R/app_config.R: 100.00%
R/app_ui.R: 100.00%
R/mod_metricBox.R: 100.00%
R/mod_metricGrid.R: 100.00%
R/mod_viewComments.R: 100.00%
Note: our test coverage GHA has been passing despite failing to calculate test coverage.
Here are some modules that currently do not have a unit test associated with them:
library(dplyr)
library(stringr)
library(purrr)
r_files <- list.files(file.path(getwd(), "R"), pattern="*.R")
t_files <- list.files(file.path(getwd(), "tests/testthat"), pattern = "*.R")
test_files <- map_chr(t_files, ~substr(.x, 6, nchar(.x))) # remove test- prefix
mod_files <- r_files[str_detect(r_files, "mod_") & str_detect(r_files, "_utils", TRUE)] %>%
str_replace_all("_", "-") %>% str_replace_all(., "mod-", "")
setdiff(mod_files, test_files) %>% tools::file_path_sans_ext()
[1] "aboutInfo" "assessmentInfo" "code-explorer" "decision-automation" "legend"
[6] "metric-rule" "metricBox" "metricGrid" "pkg-explorer" "user-roles"
[11] "viewComments"
Here are some exported objects that do not currently have tests:
all_funcs <- getNamespaceExports("riskassessment")
all_funcx <- all_funcs[!str_detect(all_funcs, stringr::regex("^[t|l]\\_"))]
t_filesx <- test_files[!str_detect(test_files, stringr::regex("^[t|l]\\-"))] %>%
str_replace_all("-", "_") %>%
str_replace_all("_R_", "_r_") %>%
str_replace_all(stringr::regex("\\.R$"), "")
setdiff(all_funcx, t_filesx)
[1] "run_app" "app_theme" "build_comm_plotly" "showComments"
[5] "initialize_raa"