Skip to content

Commit

Permalink
fixup type mechanism
Browse files Browse the repository at this point in the history
  • Loading branch information
teunbrand committed Sep 17, 2024
1 parent c62ee7e commit cbfc6d9
Showing 1 changed file with 17 additions and 15 deletions.
32 changes: 17 additions & 15 deletions R/scale-colour.R
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,12 @@ scale_colour_continuous <- function(
}

type <- type %||% "gradient"
args <- list2(...)
args <- list2(..., aesthetics = aesthetics, guide = guide)
args$call <- args$call %||% current_call()

if (is.function(type)) {
if (!any(c("...", "call") %in% fn_fmls_names(type))) {
args$call <- NULL
if (!any(c("...") %in% fn_fmls_names(type))) {
args <- args[intersect(names(args), fn_fmls_names(type))]
}
check_scale_type(exec(type, !!!args), "scale_colour_continuous", "colour")
} else if (identical(type, "gradient")) {
Expand Down Expand Up @@ -137,12 +137,12 @@ scale_fill_continuous <- function(
}

type <- type %||% "gradient"
args <- list2(...)
args <- list2(..., aesthetics = aesthetics, guide = guide)
args$call <- args$call %||% current_call()

if (is.function(type)) {
if (!any(c("...", "call") %in% fn_fmls_names(type))) {
args$call <- NULL
if (!any(c("...") %in% fn_fmls_names(type))) {
args <- args[intersect(names(args), fn_fmls_names(type))]

Check warning on line 145 in R/scale-colour.R

View check run for this annotation

Codecov / codecov/patch

R/scale-colour.R#L145

Added line #L145 was not covered by tests
}
check_scale_type(exec(type, !!!args), "scale_fill_continuous", "fill")
} else if (identical(type, "gradient")) {
Expand All @@ -159,7 +159,6 @@ scale_fill_continuous <- function(

#' @export
#' @rdname scale_colour_continuous
args <- list2(...)
scale_colour_binned <- function(
...,
palette = NULL,
Expand All @@ -178,10 +177,11 @@ scale_colour_binned <- function(
return(scale)

Check warning on line 177 in R/scale-colour.R

View check run for this annotation

Codecov / codecov/patch

R/scale-colour.R#L170-L177

Added lines #L170 - L177 were not covered by tests
}

args <- list2(..., aesthetics = aesthetics, guide = guide)
args$call <- args$call %||% current_call()
if (is.function(type)) {
if (!any(c("...", "call") %in% fn_fmls_names(type))) {
args$call <- NULL
if (!any(c("...") %in% fn_fmls_names(type))) {
args <- args[intersect(names(args), fn_fmls_names(type))]

Check warning on line 184 in R/scale-colour.R

View check run for this annotation

Codecov / codecov/patch

R/scale-colour.R#L184

Added line #L184 was not covered by tests
}
check_scale_type(exec(type, !!!args), "scale_colour_binned", "colour")
} else {
Expand Down Expand Up @@ -226,10 +226,12 @@ scale_fill_binned <- function(
)
scale

Check warning on line 227 in R/scale-colour.R

View check run for this annotation

Codecov / codecov/patch

R/scale-colour.R#L220-L227

Added lines #L220 - L227 were not covered by tests
}

args <- list2(..., aesthetics = aesthetics, guide = guide)
args$call <- args$call %||% current_call()
if (is.function(type)) {
if (!any(c("...", "call") %in% fn_fmls_names(type))) {
args$call <- NULL
if (!any(c("...") %in% fn_fmls_names(type))) {
args <- args[intersect(names(args), fn_fmls_names(type))]

Check warning on line 234 in R/scale-colour.R

View check run for this annotation

Codecov / codecov/patch

R/scale-colour.R#L234

Added line #L234 was not covered by tests
}
check_scale_type(exec(type, !!!args), "scale_fill_binned", "fill")
} else {
Expand Down Expand Up @@ -332,8 +334,8 @@ scale_colour_discrete <- function(
args$call <- args$call %||% current_call()

if (is.function(type)) {
if (!any(c("...", "call") %in% fn_fmls_names(type))) {
args$call <- NULL
if (!any(c("...") %in% fn_fmls_names(type))) {
args <- args[intersect(names(args), fn_fmls_names(type))]

Check warning on line 338 in R/scale-colour.R

View check run for this annotation

Codecov / codecov/patch

R/scale-colour.R#L338

Added line #L338 was not covered by tests
}
check_scale_type(
exec(type, !!!args),
Expand Down Expand Up @@ -370,8 +372,8 @@ scale_fill_discrete <- function(
args$call <- args$call %||% current_call()

if (is.function(type)) {
if (!any(c("...", "call") %in% fn_fmls_names(type))) {
args$call <- NULL
if (!any(c("...") %in% fn_fmls_names(type))) {
args <- args[intersect(names(args), fn_fmls_names(type))]

Check warning on line 376 in R/scale-colour.R

View check run for this annotation

Codecov / codecov/patch

R/scale-colour.R#L376

Added line #L376 was not covered by tests
}
check_scale_type(
exec(type, !!!args),
Expand Down

0 comments on commit cbfc6d9

Please sign in to comment.