Skip to content

Commit 93db424

Browse files
committed
[review] Make signature of check_review_parameter backwards compatible.
1 parent 6e54da6 commit 93db424

4 files changed

Lines changed: 24 additions & 23 deletions

File tree

R/mod_listings.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -993,7 +993,7 @@ check_mod_listings <- function(afmm, datasets, module_id, dataset_names,
993993
)
994994
)
995995

996-
check_review_parameter(afmm, datasets, dataset_names, review, err)
996+
check_review_parameter(datasets, dataset_names, review, err, afmm)
997997

998998
res <- list(errors = err[["messages"]])
999999
return(res)

R/review.R

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1289,10 +1289,6 @@ REV_report_changes <- function(h0, h1, verbose = FALSE) {
12891289
}
12901290

12911291
#' Early error feedback function for the optional review parameter
1292-
#'
1293-
#' @param afmm
1294-
#'
1295-
#' Pass-through of the server afmm parameter.
12961292
#'
12971293
#' @param datasets `[list(data.frame)]`
12981294
#'
@@ -1309,9 +1305,13 @@ REV_report_changes <- function(h0, h1, verbose = FALSE) {
13091305
#' @param err `[environment]`
13101306
#' This environment has at least one element named "messages". It is a character vector. Diagnostic messages related to
13111307
#' the configuration of the review parameter will be placed here.
1308+
#'
1309+
#' @param afmm
13121310
#'
1311+
#' Pass-through of the server afmm parameter.
1312+
#'
13131313
#' @export
1314-
check_review_parameter <- function(afmm, datasets, dataset_names, review, err) {
1314+
check_review_parameter <- function(datasets, dataset_names, review, err, afmm = NULL) {
13151315
if (is.null(review)) return(NULL)
13161316
ok <- CM$assert(
13171317
container = err,
@@ -1468,18 +1468,19 @@ check_review_parameter <- function(afmm, datasets, dataset_names, review, err) {
14681468
res <- paste(res, collapse = "<br>")
14691469
return(res)
14701470
}
1471-
1472-
dataset_list_names <- names(afmm[["data"]])
1473-
CM$assert(
1474-
container = err,
1475-
cond = !any(grepl(problematic_chars_regexp, dataset_list_names)),
1476-
msg = report_problematic_names(
1477-
paste('The dataset list name "<b>%s</b>" contains characters (%s) incompatible with the review functionality.',
1478-
"That string would be used as part of review-related folder names and those characters could cause problems",
1479-
'<a href="https://en.wikipedia.org/wiki/Filename#Problematic_characters" target="_blank">(details)<a>.',
1480-
"Please, exclude them."),
1481-
dataset_list_names)
1482-
)
1471+
if(!is.null(afmm)) {
1472+
dataset_list_names <- names(afmm[["data"]])
1473+
CM$assert(
1474+
container = err,
1475+
cond = !any(grepl(problematic_chars_regexp, dataset_list_names)),
1476+
msg = report_problematic_names(
1477+
paste('The dataset list name "<b>%s</b>" contains characters (%s) incompatible with the review functionality.',
1478+
"That string would be used as part of review-related folder names and those characters could cause problems",
1479+
'<a href="https://en.wikipedia.org/wiki/Filename#Problematic_characters" target="_blank">(details)<a>.',
1480+
"Please, exclude them."),
1481+
dataset_list_names)
1482+
)
1483+
}
14831484
dataset_names <- names(review[["datasets"]])
14841485
CM$assert(
14851486
container = err,

man/check_review_parameter.Rd

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/testthat/test-review.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -247,11 +247,11 @@ test_that("check_review_parameter warns against problematic characters in datase
247247

248248
err <- CM$container()
249249
check_review_parameter(
250-
afmm = mock_afmm,
251250
datasets = list(),
252251
dataset_names = c("not/allowed"),
253252
review = review,
254-
err = err
253+
err = err,
254+
afmm = mock_afmm
255255
)
256256

257257
expect_true(any(grepl("Problematic_characters", err[["messages"]])))

0 commit comments

Comments
 (0)