From 531f7063bb09f32a97eedebda961d108516405c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Ver=C3=ADssimo?= <211358+averissimo@users.noreply.github.com> Date: Thu, 30 Nov 2023 17:56:47 +0100 Subject: [PATCH] fix: move assert dataframe up --- R/df_label.R | 2 +- R/format.R | 2 +- R/label.R | 2 +- R/length.R | 2 +- R/metadata.R | 2 +- R/order.R | 2 +- R/type.R | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/R/df_label.R b/R/df_label.R index 5d2239e8..e5fc5545 100644 --- a/R/df_label.R +++ b/R/df_label.R @@ -51,6 +51,7 @@ xportr_df_label <- function(.df, ) metadata <- metacore } + assert_data_frame(.df) assert( combine = "or", check_r6(metadata, "Metacore", null.ok = TRUE), @@ -67,7 +68,6 @@ xportr_df_label <- function(.df, if (!is.null(domain)) attr(.df, "_xportr.df_arg_") <- domain ## End of common section - assert_data_frame(.df) # deferred after `enexpr` call ## Pull out correct metadata metadata <- metadata %||% diff --git a/R/format.R b/R/format.R index 884a731c..8c945049 100644 --- a/R/format.R +++ b/R/format.R @@ -53,6 +53,7 @@ xportr_format <- function(.df, ) metadata <- metacore } + assert_data_frame(.df) assert( combine = "or", check_r6(metadata, "Metacore", null.ok = TRUE), @@ -70,7 +71,6 @@ xportr_format <- function(.df, if (!is.null(domain)) attr(.df, "_xportr.df_arg_") <- domain ## End of common section - assert_data_frame(.df) # deferred after `enexpr` call metadata <- metadata %||% attr(.df, "_xportr.df_metadata_") %||% diff --git a/R/label.R b/R/label.R index 19497d9f..edfdba2e 100644 --- a/R/label.R +++ b/R/label.R @@ -69,6 +69,7 @@ xportr_label <- function(.df, ) metadata <- metacore } + assert_data_frame(.df) assert( combine = "or", check_r6(metadata, "Metacore", null.ok = TRUE), @@ -87,7 +88,6 @@ xportr_label <- function(.df, if (!is.null(domain)) attr(.df, "_xportr.df_arg_") <- domain ## End of common section - assert_data_frame(.df) # deferred after `enexpr` call metadata <- metadata %||% attr(.df, "_xportr.df_metadata_") %||% diff --git a/R/length.R b/R/length.R index 7f925c22..21b6b152 100644 --- a/R/length.R +++ b/R/length.R @@ -76,6 +76,7 @@ xportr_length <- function(.df, ) metadata <- metacore } + assert_data_frame(.df) assert( combine = "or", check_r6(metadata, "Metacore", null.ok = TRUE), @@ -94,7 +95,6 @@ xportr_length <- function(.df, if (!is.null(domain)) attr(.df, "_xportr.df_arg_") <- domain ## End of common section - assert_data_frame(.df) # deferred after `enexpr` call metadata <- metadata %||% attr(.df, "_xportr.df_metadata_") %||% diff --git a/R/metadata.R b/R/metadata.R index e19ea05f..e427eb43 100644 --- a/R/metadata.R +++ b/R/metadata.R @@ -41,6 +41,7 @@ #' xportr_order() #' } xportr_metadata <- function(.df, metadata, domain = NULL) { + assert_data_frame(.df) assert( combine = "or", check_r6(metadata, "Metacore", null.ok = TRUE), @@ -54,7 +55,6 @@ xportr_metadata <- function(.df, metadata, domain = NULL) { if (!is.null(domain)) attr(.df, "_xportr.df_arg_") <- domain ## End of common section - assert_data_frame(.df) # deferred after `enexpr` call structure(.df, "_xportr.df_metadata_" = metadata) } diff --git a/R/order.R b/R/order.R index 70ffbfbf..4a9d7915 100644 --- a/R/order.R +++ b/R/order.R @@ -72,6 +72,7 @@ xportr_order <- function(.df, ) metadata <- metacore } + assert_data_frame(.df) assert( combine = "or", check_r6(metadata, "Metacore", null.ok = TRUE), @@ -90,7 +91,6 @@ xportr_order <- function(.df, if (!is.null(domain)) attr(.df, "_xportr.df_arg_") <- domain ## End of common section - assert_data_frame(.df) # deferred after `enexpr` call metadata <- metadata %||% attr(.df, "_xportr.df_metadata_") %||% diff --git a/R/type.R b/R/type.R index 5814e569..53ce1cd1 100644 --- a/R/type.R +++ b/R/type.R @@ -89,6 +89,7 @@ xportr_type <- function(.df, ) metadata <- metacore } + assert_data_frame(.df) assert( combine = "or", check_r6(metadata, "Metacore", null.ok = TRUE), @@ -111,7 +112,6 @@ xportr_type <- function(.df, if (!is.null(domain)) attr(.df, "_xportr.df_arg_") <- domain ## End of common section - assert_data_frame(.df) # deferred after `enexpr` call ## Pull out correct metadata metadata <- metadata %||%