#31 Force optional arguments to be specified by name

Open Davis Vaughan DavisVaughan

No flags found

Use flags to group coverage reports by test type, project and/or folders.
Then setup custom commit statuses and notifications for each flag.

e.g., #unittest #integration

#production #enterprise

#frontend #backend

Learn more about Codecov Flags here.

Showing 4 of 11 files from the diff.

@@ -114,6 +114,10 @@
Loading
114 114
#'   This is generally used to define the anchor time to count from, which is
115 115
#'   relevant when the every value is `> 1`.
116 116
#'
117 +
#' @param ... `[dots]`
118 +
#'
119 +
#'   These dots are for future extensions and must be empty.
120 +
#'
117 121
#' @return
118 122
#' A double vector containing the distances.
119 123
#'
@@ -204,6 +208,11 @@
Loading
204 208
#'   mweek = warp_distance(x, "mweek")
205 209
#' )
206 210
#'
207 -
warp_distance <- function(x, period, every = 1L, origin = NULL) {
211 +
warp_distance <- function(x,
212 +
                          period,
213 +
                          ...,
214 +
                          every = 1L,
215 +
                          origin = NULL) {
216 +
  check_dots_empty("warp_distance", ...)
208 217
  .Call(warp_warp_distance, x, period, every, origin)
209 218
}

@@ -38,6 +38,11 @@
Loading
38 38
#' # [1969-12-28, 1970-01-02)
39 39
#' # [1970-01-02, 1970-01-07)
40 40
#' warp_boundary(x, "day", every = 5, origin = origin)
41 -
warp_boundary <- function(x, period, every = 1L, origin = NULL) {
41 +
warp_boundary <- function(x,
42 +
                          period,
43 +
                          ...,
44 +
                          every = 1L,
45 +
                          origin = NULL) {
46 +
  check_dots_empty("warp_boundary", ...)
42 47
  .Call(warp_warp_boundary, x, period, every, origin)
43 48
}

@@ -52,9 +52,11 @@
Loading
52 52
#' warp_change(x, period = "yday", every = 2, last = FALSE, endpoint = TRUE)
53 53
warp_change <- function(x,
54 54
                        period,
55 +
                        ...,
55 56
                        every = 1L,
56 57
                        origin = NULL,
57 58
                        last = TRUE,
58 59
                        endpoint = FALSE) {
60 +
  check_dots_empty("warp_change", ...)
59 61
  .Call(warp_warp_change, x, period, every, origin, last, endpoint)
60 62
}

@@ -0,0 +1,20 @@
Loading
1 +
dots_n <- function(...) {
2 +
  nargs()
3 +
}
4 +
5 +
# Like `ellipsis::check_dots_empty()` but without the import
6 +
check_dots_empty <- function(fn, ...) {
7 +
  n <- dots_n(...)
8 +
9 +
  if (n == 0L) {
10 +
    return(invisible())
11 +
  }
12 +
13 +
  msg <- paste0(
14 +
    "`...` is not empty in `", fn, "()`.\n",
15 +
    "These dots only exist to allow for future extensions and should be empty.\n",
16 +
    "Did you misspecify an argument?"
17 +
  )
18 +
19 +
  stop(msg, call. = FALSE)
20 +
}

Learn more Showing 1 files with coverage changes found.

New file R/dots.R
New
Loading file...
Files Coverage
R +9.52% 76.19%
src 94.71%
Project Totals (17 files) 94.30%
Loading