Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 3a2ec21

Browse files
committedApr 22, 2024·
new_archive validation tightening, streamlining, type stability
- Forbid `NA` `compactify` - Remove `missing` checks when `is.null` suffices - Remove redundant default code - Make local `other_keys` have more consistent typing across branches
1 parent a67a324 commit 3a2ec21

File tree

1 file changed

+5
-11
lines changed

1 file changed

+5
-11
lines changed
 

‎R/archive.R

+5-11
Original file line numberDiff line numberDiff line change
@@ -307,13 +307,13 @@ new_epi_archive <- function(
307307
}
308308

309309
# If time type is missing, then try to guess it
310-
if (missing(time_type) || is.null(time_type)) {
310+
if (is.null(time_type)) {
311311
time_type <- guess_time_type(x$time_value)
312312
}
313313

314314
# Finish off with small checks on keys variables and metadata
315-
if (missing(other_keys)) other_keys <- NULL
316-
if (missing(additional_metadata) || is.null(additional_metadata)) additional_metadata <- list()
315+
if (is.null(other_keys)) other_keys <- character(0L)
316+
if (is.null(additional_metadata)) additional_metadata <- list()
317317
if (!test_subset(other_keys, names(x))) {
318318
cli_abort("`other_keys` must be contained in the column names of `x`.")
319319
}
@@ -325,17 +325,11 @@ new_epi_archive <- function(
325325
}
326326

327327
# Conduct checks and apply defaults for `compactify`
328-
if (missing(compactify)) {
329-
compactify <- NULL
330-
}
331-
assert_logical(compactify, len = 1, null.ok = TRUE)
328+
assert_logical(compactify, len = 1, any.missing = FALSE, null.ok = TRUE)
332329

333330
# Apply defaults and conduct checks for
334331
# `clobberable_versions_start`, `versions_end`:
335-
if (missing(clobberable_versions_start)) {
336-
clobberable_versions_start <- NA
337-
}
338-
if (missing(versions_end) || is.null(versions_end)) {
332+
if (is.null(versions_end)) {
339333
versions_end <- max_version_with_row_in(x)
340334
}
341335
validate_version_bound(clobberable_versions_start, x, na_ok = TRUE)

0 commit comments

Comments
 (0)
Please sign in to comment.