Skip to content

Commit 834544a

Browse files
committed
fix more lints
1 parent 633e350 commit 834544a

28 files changed

+154
-155
lines changed

tests/testthat/test-aes-calculated.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ test_that("names surrounded by .. is calculated", {
66
expect_equal(is_calculated_aes(aes(..x.., ..x, x..)), c(TRUE, FALSE, FALSE))
77

88
# even when nested
9-
expect_equal(is_calculated_aes(aes(f(..x..))), TRUE)
9+
expect_true(is_calculated_aes(aes(f(..x..))))
1010
})
1111

1212
test_that("call to stat() is calculated", {

tests/testthat/test-aes-grouping.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ test_that("no error for aes(groupS)", {
2626
g <- add_group(df2)
2727

2828
expect_equal(nrow(g), nrow(df2))
29-
expect_equal(names(g), c("x", "y", "groupS", "group"))
29+
expect_named(g, c("x", "y", "groupS", "group"))
3030
})
3131

3232
test_that("label is not used as a grouping var", {

tests/testthat/test-coord-.R

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@ test_that("guide names are not removed by `train_panel_guides()`", {
3737
layout$setup_panel_guides(guides_list(NULL), plot$layers)
3838

3939
# Line showing change in outcome
40-
expect_equal(names(layout$panel_params[[1]]$guides$aesthetics),
41-
c("x", "y", "x.sec", "y.sec"))
40+
expect_named(layout$panel_params[[1]]$guides$aesthetics, c("x", "y", "x.sec", "y.sec"))
4241
})
4342

4443
test_that("check coord limits errors only on bad inputs", {

tests/testthat/test-coord-polar.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
test_that("polar distance is calculated correctly", {
22
dat <- data_frame(
33
theta = c(0, 2*pi, 2, 6, 6, 1, 1, 0),
4-
r = c(0, 0, 0.5, 0.5, 1, 1, 0.75, .5))
4+
r = c(0, 0, 0.5, 0.5, 1, 1, 0.75, 0.5))
55

66
scales <- list(
77
x = scale_x_continuous(limits = c(0, 2*pi)),
@@ -176,7 +176,7 @@ test_that("polar coordinates draw correctly", {
176176

177177
dat <- data_frame(
178178
theta = c(0, 2*pi, 2, 6, 6, 1, 1, 0),
179-
r = c(0, 0, 0.5, 0.5, 1, 1, 0.75, .5),
179+
r = c(0, 0, 0.5, 0.5, 1, 1, 0.75, 0.5),
180180
g = 1:8
181181
)
182182
expect_doppelganger("Rays, circular arcs, and spiral arcs",

tests/testthat/test-coord-train.R

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ test_that("NA's don't appear in breaks", {
55
ns <- names(trained)[grepl("(\\.major)|(\\.minor)$", names(trained))]
66

77
for (n in ns) {
8-
if (!is.null(trained[n]) && any(is.na(trained[n])))
8+
if (!is.null(trained[n]) && anyNA(trained[n]))
99
return(TRUE)
1010
}
1111

@@ -19,8 +19,8 @@ test_that("NA's don't appear in breaks", {
1919
# This is a test to make sure the later tests will be useful!
2020
# It's possible that changes to the way that breaks are calculated will
2121
# make it so that scale_break_positions will no longer give NA for range 1, 12
22-
expect_true(any(is.na(scale_x$break_positions())))
23-
expect_true(any(is.na(scale_y$break_positions())))
22+
expect_true(anyNA(scale_x$break_positions()))
23+
expect_true(anyNA(scale_y$break_positions()))
2424

2525
# Check the various types of coords to make sure they don't have NA breaks
2626
expect_false(any_NA_major_minor(coord_polar()$setup_panel_params(scale_x, scale_y)))

tests/testthat/test-coord_sf.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -309,8 +309,8 @@ test_that("sf_transform_xy() works", {
309309
# transform back
310310
out2 <- sf_transform_xy(out, 4326, 3347)
311311
expect_identical(data$city, out2$city)
312-
expect_true(all(abs(out2$x - data$x) < .01))
313-
expect_true(all(abs(out2$y - data$y) < .01))
312+
expect_true(all(abs(out2$x - data$x) < 0.01))
313+
expect_true(all(abs(out2$y - data$y) < 0.01))
314314

315315
})
316316

tests/testthat/test-empty-data.R

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,13 +88,13 @@ test_that("empty layers still generate one grob per panel", {
8888
geom_point() +
8989
facet_wrap(~y)
9090

91-
expect_equal(length(get_layer_grob(d)), 3)
91+
expect_length(get_layer_grob(d), 3)
9292
})
9393

9494
test_that("missing layers generate one grob per panel", {
9595
df <- data_frame(x = 1:4, y = rep(1:2, 2), g = rep(1:2, 2))
9696
base <- ggplot(df, aes(x, y)) + geom_point(shape = NA, na.rm = TRUE)
9797

98-
expect_equal(length(get_layer_grob(base)), 1)
99-
expect_equal(length(get_layer_grob(base + facet_wrap(~ g))), 2)
98+
expect_length(get_layer_grob(base), 1)
99+
expect_length(get_layer_grob(base + facet_wrap(~ g)), 2)
100100
})

tests/testthat/test-facet-strips.R

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -143,24 +143,24 @@ test_that("padding is only added if axis is present", {
143143
strip.switch.pad.grid = unit(10, "mm")
144144
)
145145
pg <- ggplotGrob(p)
146-
expect_equal(length(pg$heights), 19)
147-
expect_equal(length(pg$widths), 18)
146+
expect_length(pg$heights, 19)
147+
expect_length(pg$widths, 18)
148148

149149
pg <- ggplotGrob(
150150
p + scale_x_continuous(position = "top") +
151151
scale_y_continuous(position = "right")
152152
)
153-
expect_equal(length(pg$heights), 20)
153+
expect_length(pg$heights, 20)
154154
expect_equal(as.character(pg$heights[9]), "1cm")
155-
expect_equal(length(pg$widths), 19)
155+
expect_length(pg$widths, 19)
156156
expect_equal(as.character(pg$widths[13]), "1cm")
157157

158158
# Also add padding with negative ticks and no text (#5251)
159159
pg <- ggplotGrob(
160160
p + scale_x_continuous(labels = NULL, position = "top") +
161161
theme(axis.ticks.length.x.top = unit(-2, "mm"))
162162
)
163-
expect_equal(length(pg$heights), 20)
163+
expect_length(pg$heights, 20)
164164
expect_equal(as.character(pg$heights[9]), "1cm")
165165

166166
# Inverse should be true when strips are switched
@@ -172,17 +172,17 @@ test_that("padding is only added if axis is present", {
172172
)
173173

174174
pg <- ggplotGrob(p)
175-
expect_equal(length(pg$heights), 20)
175+
expect_length(pg$heights, 20)
176176
expect_equal(as.character(pg$heights[13]), "1cm")
177-
expect_equal(length(pg$widths), 19)
177+
expect_length(pg$widths, 19)
178178
expect_equal(as.character(pg$widths[7]), "1cm")
179179

180180
pg <- ggplotGrob(
181181
p + scale_x_continuous(position = "top") +
182182
scale_y_continuous(position = "right")
183183
)
184-
expect_equal(length(pg$heights), 19)
185-
expect_equal(length(pg$widths), 18)
184+
expect_length(pg$heights, 19)
185+
expect_length(pg$widths, 18)
186186
})
187187

188188
test_that("y strip labels are rotated when strips are switched", {

tests/testthat/test-fortify.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ test_that("spatial polygons have correct ordering", {
1111
y - dely,y - dely,y + dely,y + dely,y - dely), ncol = 2))
1212
}
1313

14-
make_hole <- function(x = 0, y = 0, height = .5, width = .5){
14+
make_hole <- function(x = 0, y = 0, height = 0.5, width = 0.5){
1515
p <- make_square(x = x, y = y, height = height, width = width)
1616
p@hole <- TRUE
1717
p

tests/testthat/test-geom-boxplot.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ test_that("boxes with variable widths do not overlap", {
7373
d <- get_layer_data(p)[c("xmin", "xmax")]
7474
xid <- find_x_overlaps(d)
7575

76-
expect_false(any(duplicated(xid)))
76+
expect_false(anyDuplicated(xid) > 0)
7777
})
7878

7979
test_that("boxplots with a group size >1 error", {

0 commit comments

Comments
 (0)