-
Notifications
You must be signed in to change notification settings - Fork 48
Description
Summary
val_class_or_null() and val_class_and_single() are exported but marked with TODO comments indicating they should be removed once finetune is updated. Each has a corresponding unexported helper (check_class_or_null(), check_class_and_single()).
Locations
val_class_or_null() and check_class_or_null():
Lines 563 to 585 in 3544816
| check_class_or_null <- function(x, cls = "numeric") { | |
| inherits(x, cls) | is.null(x) | |
| } | |
| #' @export | |
| #' @keywords internal | |
| #' @rdname empty_ellipses | |
| #' @param cls A character vector of possible classes | |
| #' @param where A character string for the calling function. | |
| val_class_or_null <- function(x, cls = "numeric", where = NULL) { | |
| cl <- match.call() | |
| fine <- check_class_or_null(x, cls) | |
| cls <- paste(cls, collapse = " or ") | |
| if (!fine) { | |
| msg <- glue::glue("Argument '{deparse(cl$x)}' should be a {cls} or NULL") | |
| if (!is.null(where)) { | |
| msg <- glue::glue(msg, " in `{where}`") | |
| } | |
| rlang::abort(msg) | |
| } | |
| invisible(NULL) | |
| } | |
| # TODO remove this once finetune is updated |
val_class_and_single() and check_class_and_single():
Lines 587 to 609 in 3544816
| check_class_and_single <- function(x, cls = "numeric") { | |
| isTRUE(inherits(x, cls) & length(x) == 1) | |
| } | |
| #' @export | |
| #' @keywords internal | |
| #' @rdname empty_ellipses | |
| val_class_and_single <- function(x, cls = "numeric", where = NULL) { | |
| cl <- match.call() | |
| fine <- check_class_and_single(x, cls) | |
| cls <- paste(cls, collapse = " or ") | |
| if (!fine) { | |
| msg <- glue::glue( | |
| "Argument '{deparse(cl$x)}' should be a single {cls} value" | |
| ) | |
| if (!is.null(where)) { | |
| msg <- glue::glue(msg, " in `{where}`") | |
| } | |
| rlang::abort(msg) | |
| } | |
| invisible(NULL) | |
| } | |
| # TODO remove this once finetune is updated |
Current status
Both val_class_* functions are exported for finetune's benefit. The TODO comments on lines 585 and 609 say:
# TODO remove this once finetune is updatedNeither function is called within tune itself (R/, tests/, or inst/).
Suggested fix
Check whether finetune still uses these functions. If so, open an issue on finetune. Deprecate all four functions (val_class_or_null(), check_class_or_null(), val_class_and_single(), check_class_and_single()) and remove their export/documentation entries.