Skip to content

Commit

Permalink
lintr and style
Browse files Browse the repository at this point in the history
remove previous results
  • Loading branch information
zsigmas committed Jun 3, 2024
1 parent 043b9d3 commit 71dcc30
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 3,740 deletions.
2 changes: 1 addition & 1 deletion .lintr
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ linters: linters_with_defaults(
indentation_linter = NULL,
trailing_whitespace_linter = NULL
)
exclusions: as.list(setdiff(list.files(".", recursive = T),list.files("R", recursive = T, full.names = T)))

Binary file removed inst/validation/results/val_param.rds
Binary file not shown.
3,699 changes: 0 additions & 3,699 deletions inst/validation/results/val_report.html

This file was deleted.

65 changes: 33 additions & 32 deletions inst/validation/run_validation.R
Original file line number Diff line number Diff line change
@@ -1,39 +1,40 @@
local({
# This is evaluated inside a local because, otherwise, all the variables created in the chunks of the rendered
# document leak into the environment
# This is evaluated inside a local because, otherwise, all the variables created in the chunks of the rendered
# document leak into the environment

validation_root <- "./inst/validation"
validation_report_rmd <- file.path(validation_root, "val_report.Rmd")
validation_report_html <- "val_report.html"
validation_results <- file.path(validation_root, "results")
val_param_rds <- file.path(validation_results, "val_param.rds")
validation_root <- "./inst/validation"
validation_report_rmd <- file.path(validation_root, "val_report.Rmd")
validation_report_html <- "val_report.html"
validation_results <- file.path(validation_root, "results")
val_param_rds <- file.path(validation_results, "val_param.rds")

stopifnot(dir.exists(validation_root))
stopifnot(file.exists(validation_report_rmd))
stopifnot(dir.exists(validation_root))
stopifnot(file.exists(validation_report_rmd))

stopifnot(dir.exists(validation_results))
unlink(list.files(validation_results))
stopifnot(dir.exists(validation_results))
unlink(list.files(validation_results))

saveRDS(
list(
package = pkg_name,
tests = test_results,
version = pkg_version
),
val_param_rds
)
saveRDS(
list(
package = pkg_name,
tests = test_results,
version = pkg_version
),
val_param_rds
)

rmarkdown::render(
input = validation_report_rmd,
params = list(
package = pkg_name,
tests = test_results,
version = pkg_version
),
output_dir = validation_results,
output_file = validation_report_html
)
rmarkdown::render(
input = validation_report_rmd,
params = list(
package = pkg_name,
tests = test_results,
version = pkg_version
),
output_dir = validation_results,
output_file = validation_report_html
)

# We use one of the leaked variables, created inside the validation report to asses if the validation is succesful or not
VALIDATION_PASSED
})
# We use one of the leaked variables, created inside the validation report to asses if the validation is
# succesful or not
VALIDATION_PASSED
})
16 changes: 8 additions & 8 deletions inst/validation/val_report_child.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ tests[["spec_paste"]] <- vapply(tests[["spec"]], function(x) paste(x, collapse =
tests[["desc"]] <- paste0("(#", seq_len(nrow(tests)), "): ", tests[["test"]])
tests[["with_spec"]] <- vapply(tests[["spec_id"]], Negate(is.null), FUN.VALUE = logical(1))
spec_tests <- tests[tests[["with_spec"]],]
no_spec_tests <- tests[!tests[["with_spec"]],]
spec_tests <- tests[tests[["with_spec"]], ]
no_spec_tests <- tests[!tests[["with_spec"]], ]
declared_spec <- vdoc[["spec_id_list"]]
tested_spec <- unique(unlist(tests[["spec_id"]]))
Expand All @@ -55,27 +55,27 @@ n_skip_dec <- sum(mask_skipped & mask_declared)
n_uncov <- length(uncovered_spec)
n_undec <- sum(!mask_declared)
render_spec_table <- function(t){
render_spec_table <- function(t) {
t <- t[trac_matrix_col]
colnames(t) <- names(trac_matrix_col)
t <- t[order(t[["Spec ID"]]),]
DT::datatable(t, options = list(dom = "ltp"), filter = list(position = "top"))
t <- t[order(t[["Spec ID"]]), ]
DT::datatable(t, options = list(dom = "ltp"), filter = list(position = "top"))
}
data_frame_by_row <- function(colnames, data){
data_frame_by_row <- function(colnames, data) {
n <- length(data)
n_cols <- length(colnames)
stopifnot(n %% n_cols == 0)
columns <- vector("list", length = n_cols)
for(i in 1:n_cols) columns[[i]] <- unlist(data[seq(i, n, n_cols)])
for (i in 1:n_cols) columns[[i]] <- unlist(data[seq(i, n, n_cols)])
do.call(data.frame, setNames(columns, colnames))
}
# Select columns to be included in the tables ----
trac_matrix_col <- c("Spec ID" = "spec_id_paste", "Spec" = "spec_paste", "Test Desc" = "desc", "File" = "file")
# Check that validation passes and set title ----
VALIDATION_PASSED <- n_fail_dec == 0 && n_uncov == 0 && n_undec == 0 && n_uncov == 0
VALIDATION_PASSED <- n_fail_dec == 0 && n_uncov == 0 && n_undec == 0 && n_uncov == 0 # nolint
result_symbol <- if (VALIDATION_PASSED) "\U02705" else "\U274C"
title <- paste(result_symbol, params[["package"]], params[["version"]])
Expand Down

0 comments on commit 71dcc30

Please sign in to comment.