diff --git a/R/class-summary_PKNCAresults.R b/R/class-summary_PKNCAresults.R index 49207854..8a8d10aa 100644 --- a/R/class-summary_PKNCAresults.R +++ b/R/class-summary_PKNCAresults.R @@ -488,15 +488,7 @@ summarize_PKNCAresults_parameter <- function(data, parameter, subject_col, inclu current_summary_instructions <- PKNCA.set.summary()[[parameter]] if (is.null(current_summary_instructions)) { - # nocov start - rlang::abort( - sprintf( - "No summary function is set for parameter %s. Please set it with PKNCA.set.summary and report this as a bug in PKNCA.", - parameter - ), - class = "pknca_error_no_summary_function" - ) - # nocov end + rlang::abort(sprintf("No summary function is set for parameter %s. Please set it with PKNCA.set.summary and report this as a bug in PKNCA.", parameter), class = "pknca_error_no_summary_function") # nocov } point <- current_summary_instructions$point(current_data[[number_col]]) diff --git a/R/interpolate.conc.R b/R/interpolate.conc.R index 702549cc..3eeb6354 100644 --- a/R/interpolate.conc.R +++ b/R/interpolate.conc.R @@ -422,15 +422,7 @@ interp.extrap.conc.dose <- function(conc, time, TRUE~"unknown") # should never happen if (any(mask_unknown <- data_all$event %in% "unknown")) { # All events should be accounted for already - # nocov start - rlang::abort( - sprintf( - "Unknown event in interp.extrap.conc.dose at time(s): %s (Please report this as a bug)", - paste(unique(data_all$time[mask_unknown]), collapse = ", ") - ), - class = "pknca_error_internal_unknown_event" - ) - # nocov end + rlang::abort(sprintf("Unknown event in interp.extrap.conc.dose at time(s): %s (Please report this as a bug)", paste(unique(data_all$time[mask_unknown]), collapse = ", ")), class = "pknca_error_internal_unknown_event") # nocov } # Remove "output_only" from event_before and event_after simple_locf <- function(x, missing_val) { @@ -475,15 +467,7 @@ interp.extrap.conc.dose <- function(conc, time, } if (any(mask_no_method <- is.na(data_all$method))) { # This should never happen, all eventualities should be covered - # nocov start - rlang::abort( - sprintf( - "No method for imputing concentration at time(s): %s", - paste(unique(data_all$time[mask_no_method]), collapse = ", ") - ), - class = "pknca_error_no_interp_method" - ) - # nocov end + rlang::abort(sprintf("No method for imputing concentration at time(s): %s", paste(unique(data_all$time[mask_no_method]), collapse = ", ")), class = "pknca_error_no_interp_method") # nocov } # Filter to the requested time points and output data_out <- data_all[data_all$out,,drop=FALSE] @@ -511,17 +495,7 @@ iecd_impossible_select <- function(x) { x$event_after %in% c("conc_dose_iv_bolus_after", "dose_iv_bolus_after")) } iecd_impossible_value <- function(data_all, current_idx, ...) { - # nocov start - rlang::abort( - sprintf( - "Impossible combination requested for interp.extrap.conc.dose (please report this as a bug). event_before: %s, event: %s, event_after: %s", - data_all$event_before[current_idx], - data_all$event[current_idx], - data_all$event_after[current_idx] - ), - class = "pknca_error_internal_impossible_event_combination" - ) - # nocov end + rlang::abort(sprintf("Impossible combination requested for interp.extrap.conc.dose (please report this as a bug). event_before: %s, event: %s, event_after: %s", data_all$event_before[current_idx], data_all$event[current_idx], data_all$event_after[current_idx]), class = "pknca_error_internal_impossible_event_combination") # nocov } # Observed concentration #### diff --git a/R/prepare_data.R b/R/prepare_data.R index 58ef0be3..2d8c5850 100644 --- a/R/prepare_data.R +++ b/R/prepare_data.R @@ -161,7 +161,7 @@ prepare_PKNCAconc <- function(.dat, extra_cols = character()) { group_cols_selected=group_cols_selected ) } else { - stop("Please report this as a bug: Invalid data_name") # nocov + rlang::abort("Please report this as a bug: Invalid data_name", class = "pknca_error_internal_invalid_data_name") # nocov } ret } @@ -302,10 +302,11 @@ check_reserved_column_names <- function(x) { #' @noRd #' @keywords Internal standardize_column_names <- function(x, cols, group_cols=NULL, insert_if_missing=list()) { - checkmate::assert_list(cols, .var.name = "cols") - checkmate::assert_named(cols, .var.name = "cols") + checkmate::assert_list(cols) + checkmate::assert_named(cols) + # `.var.name` is kept here because the default would report `unlist(cols)` checkmate::assert_subset(unlist(cols), choices = names(x), .var.name = "cols") - checkmate::assert_character(group_cols, null.ok = TRUE,.var.name = "group_cols") + checkmate::assert_character(group_cols, null.ok = TRUE) if (!is.null(group_cols) && (length(group_cols) > 0)) { # Give a clear error message if group columns overlap mask_overlap_colvalues <- group_cols %in% unlist(cols) diff --git a/R/set_and_assert_intervals.R b/R/set_and_assert_intervals.R index a2529245..4804f396 100644 --- a/R/set_and_assert_intervals.R +++ b/R/set_and_assert_intervals.R @@ -34,7 +34,7 @@ set_intervals <- function(data, intervals) { #' @export assert_intervals <- function(intervals, data) { checkmate::assert_data_frame(intervals) - checkmate::assert_class(data, classes = "PKNCAdata", .var.name = "data") + checkmate::assert_class(data, classes = "PKNCAdata") allowed_columns <- c( diff --git a/R/time.above.R b/R/time.above.R index b3b168f6..8178eafd 100644 --- a/R/time.above.R +++ b/R/time.above.R @@ -22,12 +22,12 @@ pk.calc.time_above <- function(conc, time, arglist <- list(...) method <- PKNCA.choose.option(name="auc.method", value=arglist$method, options=options) if (missing(conc)) { - rlang::abort("conc must be given", class = "pknca_error_time_above_missing_conc") + rlang::abort("conc must be given", class = "pknca_error_time_above_missing_conc") } if (missing(time)) { - rlang::abort("time must be given", class = "pknca_error_time_above_missing_time") + rlang::abort("time must be given", class = "pknca_error_time_above_missing_time") } - checkmate::assert_number(conc_above, na.ok = FALSE) + checkmate::assert_number(conc_above, na.ok = FALSE) if (check) { assert_conc_time(conc = conc, time = time) } @@ -77,7 +77,7 @@ pk.calc.time_above <- function(conc, time, ) } else { # Should be caught by the method assignment above - stop("Invalid 'method', please report this as a bug: ", method) # nocov + rlang::abort(sprintf("Invalid 'method', please report this as a bug: %s", method), class = "pknca_error_internal_invalid_time_above_method") # nocov } ret } @@ -87,9 +87,9 @@ add.interval.col("time_above", values=c(FALSE, TRUE), unit_type="time", pretty_name="Time above Concentration", - desc="Time above a given concentration", - pptestcd_cdisc="TAT", - pptest_cdisc="Time Above Threshold") + desc="Time above a given concentration", + pptestcd_cdisc="TAT", + pptest_cdisc="Time Above Threshold") PKNCA.set.summary( name="time_above", description="arithmetic mean and standard deviation", diff --git a/R/unit-support.R b/R/unit-support.R index 461fce8a..3127813f 100644 --- a/R/unit-support.R +++ b/R/unit-support.R @@ -126,15 +126,7 @@ pknca_units_table.default <- function(concu, doseu, amountu, timeu, extra_cols <- setdiff(ret$PPTESTCD, names(get.interval.cols())) if (length(extra_cols) > 0) { - # nocov start - rlang::abort( - sprintf( - "Please report a bug. Unknown NCA parameters have units defined: %s", - paste(extra_cols, collapse = ", ") - ), - class = "pknca_error_internal_unknown_nca_units" - ) - # nocov end + rlang::abort(sprintf("Please report a bug. Unknown NCA parameters have units defined: %s", paste(extra_cols, collapse = ", ")), class = "pknca_error_internal_unknown_nca_units") # nocov } # Apply conversion factors