-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Fix some lints in the tests
folder
#6051
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for putting together a PR! I like almost all of these changes, with the exception of some relating to anyDuplicated()
.
tests/testthat/test-geom-boxplot.R
Outdated
@@ -73,7 +73,7 @@ test_that("boxes with variable widths do not overlap", { | |||
d <- get_layer_data(p)[c("xmin", "xmax")] | |||
xid <- find_x_overlaps(d) | |||
|
|||
expect_false(any(duplicated(xid))) | |||
expect_false(anyDuplicated(xid) > 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I get that anyDuplicated()
is more efficient, but the mental effort to understand what this expectation is doing is increased by this change.
expect_false(anyDuplicated(xid) > 0) | |
expect_equal(anyDuplicated(xid), 0) |
@@ -32,7 +32,7 @@ test_that("rectangles are dodged", { | |||
p <- ggplot(df, aes(xmin = xmin, xmax = xmax, ymin = ymin, ymax = ymax)) + | |||
geom_rect(aes(fill = fill), position = "dodge2", alpha = 0.8) | |||
|
|||
expect_false(any(duplicated(find_x_overlaps(get_layer_data(p))))) | |||
expect_false(anyDuplicated(find_x_overlaps(get_layer_data(p))) > 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
expect_false(anyDuplicated(find_x_overlaps(get_layer_data(p))) > 0) | |
expect_equal(anyDuplicated(find_x_overlaps(get_layer_data(p))), 0) |
@@ -44,7 +44,7 @@ test_that("cols at the same x position are dodged", { | |||
p <- ggplot(df, aes(1, n, fill = x)) + | |||
geom_col(position = "dodge2", alpha = 0.5) | |||
|
|||
expect_false(any(duplicated(find_x_overlaps(get_layer_data(p))))) | |||
expect_false(anyDuplicated(find_x_overlaps(get_layer_data(p))) > 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
expect_false(anyDuplicated(find_x_overlaps(get_layer_data(p))) > 0) | |
expect_equal(anyDuplicated(find_x_overlaps(get_layer_data(p))), 0) |
Fair enough, I also think |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great, thanks for this!
Same as #6050 but used
flint::fix_dir("tests")
this time (to avoid having too many changed files in the same PR).Changes include:
expect_equal(names(x), ...) -> expect_named(x, ...)
expect_equal(x, NULL) -> expect_null(x)
expect_equal(x, TRUE) -> expect_true(x)
and more.