Skip to content

Commit 898c944

Browse files
committed
warn about ... when not empty
1 parent 9ae0cb7 commit 898c944

File tree

4 files changed

+23
-1
lines changed

4 files changed

+23
-1
lines changed

R/all-classes.R

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,7 @@ class_theme <- S7::new_class(
218218
validate = S7::class_logical
219219
),
220220
constructor = function(elements, complete, validate, ...) {
221+
warn_dots_empty()
221222
S7::new_object(
222223
elements,
223224
complete = complete,
@@ -238,14 +239,15 @@ class_theme <- S7::new_class(
238239
#' @param ... Reserved for future expansion.
239240
#'
240241
#' @details
241-
#' All members of `labels` are expected to be named and unique.
242+
#' All members of `labels` are expected to be named and names should be unique.
242243
#'
243244
#'
244245
#' @keywords internal
245246
#' @export
246247
class_labels <- S7::new_class(
247248
"labels", parent = class_S3_gg,
248249
constructor = function(labels, ...) {
250+
warn_dots_empty()
249251
S7::new_object(labels)
250252
},
251253
validator = function(self) {
@@ -281,6 +283,7 @@ class_labels <- S7::new_class(
281283
class_mapping <- S7::new_class(
282284
"mapping", parent = class_S3_gg,
283285
constructor = function(x, env = globalenv(), ...) {
286+
warn_dots_empty()
284287
check_object(x, is.list, "a {.cls list}")
285288
x <- lapply(x, new_aesthetic, env = env)
286289
x <- S7::new_object(x)
@@ -346,6 +349,7 @@ class_ggplot <- S7::new_class(
346349
plot_env = parent.frame(),
347350
...
348351
) {
352+
warn_dots_empty()
349353
S7::new_object(
350354
S7::S7_object(),
351355
data = data,
@@ -389,6 +393,7 @@ class_ggplot_built <- S7::new_class(
389393
plot = class_ggplot
390394
),
391395
constructor = function(data = NULL, layout = NULL, plot = NULL, ...) {
396+
warn_dots_empty()
392397
if (is.null(data) || is.null(layout) || is.null(plot)) {
393398
cli::cli_abort(
394399
"The {.cls ggplot_built} class should be constructed by {.fn ggplot_build}."

R/margins.R

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
margin <- S7::new_class(
99
"margin", parent = S7::new_S3_class(c("simpleUnit", "unit", "unit_v2")),
1010
constructor = function(t = 0, r = 0, b = 0, l = 0, unit = "pt", ...) {
11+
warn_dots_empty()
1112
lens <- c(length(t), length(r), length(b), length(l))
1213
if (any(lens != 1)) {
1314
incorrect <- c("t", "r", "b", "l")[lens != 1]

R/theme-elements.R

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ element_rect <- S7::new_class(
140140
constructor = function(fill = NULL, colour = NULL, linewidth = NULL,
141141
linetype = NULL, color = NULL, linejoin = NULL,
142142
inherit.blank = FALSE, size = deprecated(), ...){
143+
warn_dots_empty()
143144
if (lifecycle::is_present(size)) {
144145
deprecate_warn0("3.4.0", "element_rect(size)", "element_rect(linewidth)")
145146
linewidth <- size
@@ -174,6 +175,7 @@ element_line <- S7::new_class(
174175
lineend = NULL, color = NULL, linejoin = NULL,
175176
arrow = NULL, arrow.fill = NULL,
176177
inherit.blank = FALSE, size = deprecated(), ...) {
178+
warn_dots_empty()
177179
if (lifecycle::is_present(size)) {
178180
deprecate_warn0("3.4.0", "element_line(size)", "element_line(linewidth)")
179181
linewidth <- size
@@ -228,6 +230,7 @@ element_text <- S7::new_class(
228230
size = NULL, hjust = NULL, vjust = NULL, angle = NULL,
229231
lineheight = NULL, color = NULL, margin = NULL,
230232
debug = NULL, inherit.blank = FALSE, ...) {
233+
warn_dots_empty()
231234
n <- max(
232235
length(family), length(face), length(colour), length(size),
233236
length(hjust), length(vjust), length(angle), length(lineheight)
@@ -272,6 +275,7 @@ element_polygon <- S7::new_class(
272275
constructor = function(fill = NULL, colour = NULL, linewidth = NULL,
273276
linetype = NULL, color = NULL, linejoin = NULL,
274277
inherit.blank = FALSE, ...) {
278+
warn_dots_empty()
275279
colour <- color %||% colour
276280
S7::new_object(
277281
S7::S7_object(),
@@ -293,6 +297,7 @@ element_point <- S7::new_class(
293297
),
294298
constructor = function(colour = NULL, shape = NULL, size = NULL, fill = NULL,
295299
stroke = NULL, color = NULL, inherit.blank = FALSE, ...) {
300+
warn_dots_empty()
296301
S7::new_object(
297302
S7::S7_object(),
298303
colour = color %||% colour, fill = fill, shape = shape, size = size,
@@ -331,6 +336,7 @@ element_geom <- S7::new_class(
331336
pointsize = NULL, pointshape = NULL,
332337
colour = NULL, color = NULL, fill = NULL,
333338
...) {
339+
warn_dots_empty()
334340
if (!is.null(fontsize)) {
335341
fontsize <- fontsize / .pt
336342
}

R/utilities.R

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -850,6 +850,16 @@ warn_dots_used <- function(env = caller_env(), call = caller_env()) {
850850
)
851851
}
852852

853+
warn_dots_empty <- function(env = caller_env(), call = caller_env()) {
854+
check_dots_empty(
855+
env = env, call = call,
856+
error = function(cnd) {
857+
msg <- gsub("\n", "\f", cnd_message(cnd))
858+
cli::cli_warn(msg, call = call)
859+
}
860+
)
861+
}
862+
853863
# TODO: Replace me if rlang/#1730 gets implemented
854864
# Similar to `rlang::check_installed()` but returns boolean and misses
855865
# features such as versions, comparisons and using {pak}.

0 commit comments

Comments
 (0)