Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use scalar logical operators in conditionals #139

Merged
merged 1 commit into from
May 31, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions R/geom_signif.R
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,11 @@
orientation = NA,
...) {
if (manual) {
if (!is.null(data) & !is.null(mapping)) {
if (!is.null(data) && !is.null(mapping)) {
if (!"x" %in% names(data)) mapping$x <- 1
if (!"y" %in% names(data)) mapping$y <- 1
} else {
stop("If manual mode is selected you need to provide the data and mapping parameters")

Check warning on line 114 in R/geom_signif.R

View workflow job for this annotation

GitHub Actions / lint

file=R/geom_signif.R,line=114,col=7,[condition_call_linter] Use stop(., call. = FALSE) not to display the call in an error message.
}
}

Expand Down Expand Up @@ -165,7 +165,7 @@
extra_params = c("na.rm", "orientation"),
setup_params = function(data, params) {
params$flipped_aes <- ggplot2::has_flipped_aes(data, params)
return(params)

Check warning on line 168 in R/geom_signif.R

View workflow job for this annotation

GitHub Actions / lint

file=R/geom_signif.R,line=168,col=5,[return_linter] Use implicit return behavior; explicit return() is not needed.
},
draw_key = function(...) {
grid::nullGrob()
Expand Down Expand Up @@ -276,16 +276,16 @@
params <- list(na.rm = na.rm, ...)

if (identical(stat, "signif")) {
if (!is.null(data) & !is.null(mapping) & !manual) {
if (!is.null(data) && !is.null(mapping) && !manual) {
warning("You have set data and mapping, are you sure that manual = FALSE is correct?")

Check warning on line 280 in R/geom_signif.R

View workflow job for this annotation

GitHub Actions / lint

file=R/geom_signif.R,line=280,col=7,[condition_call_linter] Use warning(., call. = FALSE) not to display the call in an error message.
}

if (manual) {
if (is.null(mapping$annotations)) {
stop("Manual mode only works if with 'annotations' is provided in mapping")

Check warning on line 285 in R/geom_signif.R

View workflow job for this annotation

GitHub Actions / lint

file=R/geom_signif.R,line=285,col=9,[condition_call_linter] Use stop(., call. = FALSE) not to display the call in an error message.
}

if (!is.null(data) & !is.null(mapping)) {
if (!is.null(data) && !is.null(mapping)) {
if (!"x" %in% names(mapping)) {
if ("xmin" %in% names(mapping)) {
mapping$x <- mapping$xmin
Expand All @@ -302,7 +302,7 @@
}
}
} else {
stop("If manual mode is selected you need to provide the data and mapping parameters")

Check warning on line 305 in R/geom_signif.R

View workflow job for this annotation

GitHub Actions / lint

file=R/geom_signif.R,line=305,col=9,[condition_call_linter] Use stop(., call. = FALSE) not to display the call in an error message.
}
}

Expand Down Expand Up @@ -345,7 +345,7 @@
}


StatSignif <- ggplot2::ggproto(

Check warning on line 348 in R/geom_signif.R

View workflow job for this annotation

GitHub Actions / lint

file=R/geom_signif.R,line=348,col=1,[cyclocomp_linter] Reduce the cyclomatic complexity of this function from 55 to at most 25.
"StatSignif",
ggplot2::Stat,
required_aes = c("x", "y", "group"),
Expand All @@ -356,18 +356,18 @@
data <- ggplot2::flip_data(data, params$flipped_aes)

if (any(data$group == -1)) {
stop("Can only handle data with groups that are plotted on the x-axis")

Check warning on line 359 in R/geom_signif.R

View workflow job for this annotation

GitHub Actions / lint

file=R/geom_signif.R,line=359,col=7,[condition_call_linter] Use stop(., call. = FALSE) not to display the call in an error message.
}

if (is.character(params$test)) params$test <- match.fun(params$test)
params$complete_data <- data

if (is.null(params$xmin) != is.null(params$xmax) || length(params$xmin) != length(params$xmax)) {
stop("If xmin or xmax is set, the other one also needs to be set and they need to contain the same number of values")

Check warning on line 366 in R/geom_signif.R

View workflow job for this annotation

GitHub Actions / lint

file=R/geom_signif.R,line=366,col=7,[condition_call_linter] Use stop(., call. = FALSE) not to display the call in an error message.

Check warning on line 366 in R/geom_signif.R

View workflow job for this annotation

GitHub Actions / lint

file=R/geom_signif.R,line=366,col=121,[line_length_linter] Lines should not be more than 120 characters. This line is 123 characters.
}

if (!is.null(params$xmin) && !is.null(params$comparisons)) {
stop("Set either the xmin, xmax values or the comparisons")

Check warning on line 370 in R/geom_signif.R

View workflow job for this annotation

GitHub Actions / lint

file=R/geom_signif.R,line=370,col=7,[condition_call_linter] Use stop(., call. = FALSE) not to display the call in an error message.
}

if (!is.null(params$xmin) && is.null(params$y_position)) {
Expand Down Expand Up @@ -460,7 +460,7 @@
result <- lapply(comparisons, function(comp) {
i <<- i + 1
# All entries in group should be the same
if (scales$x$map(comp[1]) == data$group[1] | manual) {
if (scales$x$map(comp[1]) == data$group[1] || manual) {
test_result <- if (is.null(annotations)) {
group_1 <- complete_data$y[complete_data$x == scales$x$map(comp[1]) &
complete_data$PANEL == data$PANEL[1]]
Expand Down
Loading