Skip to content

Commit 0ba6920

Browse files
Avoid && in stopifnot() conditions
1 parent 3362108 commit 0ba6920

File tree

9 files changed

+10
-10
lines changed

9 files changed

+10
-10
lines changed

R/bbox.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
is.na.bbox = function(x) identical(x, NA_bbox_)
66

77
bb_wrap = function(bb) {
8-
stopifnot(is.numeric(bb) && length(bb) == 4)
8+
stopifnot(is.numeric(bb), length(bb) == 4)
99
structure(as.double(bb), names = c("xmin", "ymin", "xmax", "ymax"), class = "bbox")
1010
}
1111

R/geom-predicates.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ st_geos_binop = function(op, x, y, par = 0.0, pattern = NA_character_,
101101
#' st_queen <- function(a, b = a) st_relate(a, b, pattern = "F***T****")
102102
st_relate = function(x, y, pattern = NA_character_, sparse = !is.na(pattern)) {
103103
if (!is.na(pattern)) {
104-
stopifnot(is.character(pattern) && length(pattern) == 1 && nchar(pattern) == 9)
104+
stopifnot(is.character(pattern), length(pattern) == 1, nchar(pattern) == 9)
105105
st_geos_binop("relate_pattern", x, y, pattern = pattern, sparse = sparse)
106106
} else
107107
st_geos_binop("relate", x, y, sparse = FALSE)

R/graticule.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ st_graticule = function(x = c(-180,-90,180,90), crs = st_crs(x),
9090
st_bbox(x)
9191
else
9292
x
93-
stopifnot(is.numeric(bb) && length(bb) == 4)
93+
stopifnot(is.numeric(bb), length(bb) == 4)
9494

9595
if (isTRUE(st_is_longlat(crs)))
9696
bb = trim_bb(bb, margin)
@@ -206,7 +206,7 @@ graticule_attributes = function(df) {
206206
}
207207

208208
trim_bb = function(bb = c(-180, -90, 180, 90), margin, wrap=c(-180,180)) {
209-
stopifnot(margin > 0 && margin <= 1.0)
209+
stopifnot(margin > 0, margin <= 1.0)
210210
fr = 1.0 - margin
211211
if (min(bb[c(1,3)]) >= -15. && max(bb[c(1,3)]) > 195.) { # 0-360 span:
212212
wrap=c(0., 360.)

R/m_range.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
is.na.m_range = function(x) identical(x, NA_m_range_)
66

77
mb_wrap = function(mb) {
8-
stopifnot(is.numeric(mb) && length(mb) == 2)
8+
stopifnot(is.numeric(mb), length(mb) == 2)
99
structure(mb, names = c("mmin", "mmax"), class = "m_range")
1010
}
1111

R/sfg.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ MtrxSet = function(x, dim = "XYZ", type, needClosed = FALSE) {
3838

3939
# creates object of class c(dim, type, "sfg") from list x, d, possibly checking rings are closed
4040
MtrxSetSet = function(x, dim = "XYZ", type, needClosed = FALSE) {
41-
stopifnot(is.list(x) && all(vapply(x, is.list, TRUE)))
41+
stopifnot(is.list(x), vapply(x, is.list, TRUE))
4242
if (length(x)) {
4343
nc = unique(unlist(lapply(x, function(y) vapply(y, ncol, 0L))))
4444
if (length(nc) != 1)

R/transform.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ st_wrap_dateline.sfc = function(x, options = "WRAPDATELINE=YES", quiet = TRUE) {
183183
else
184184
stopifnot(st_is_longlat(x))
185185
stopifnot(is.character(options))
186-
stopifnot(is.logical(quiet) && length(quiet) == 1)
186+
stopifnot(is.logical(quiet), length(quiet) == 1)
187187
st_sfc(CPL_wrap_dateline(x, options, quiet), crs = st_crs(x))
188188
}
189189

R/wkb.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ st_as_sfc.WKB = function(x, ..., EWKB = FALSE, spatialite = FALSE, pureR = FALSE
4343
else
4444
structure(CPL_hex_to_raw(vapply(x, skip0x, USE.NAMES = FALSE, "")), class = "WKB")
4545
} else # direct call with raw:
46-
stopifnot(inherits(x, "WKB") && all(vapply(x, is.raw, TRUE))) # WKB as raw
46+
stopifnot(inherits(x, "WKB"), vapply(x, is.raw, TRUE)) # WKB as raw
4747
if (any(lengths(x) == 0))
4848
stop("cannot read WKB object from zero-length raw vector")
4949
ret = if (pureR)

R/z_range.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
is.na.z_range = function(x) identical(x, NA_z_range_)
66

77
zb_wrap = function(zb) {
8-
stopifnot(is.numeric(zb) && length(zb) == 2)
8+
stopifnot(is.numeric(zb), length(zb) == 2)
99
structure(zb, names = c("zmin", "zmax"), class = "z_range")
1010
}
1111

demo/bm_wkb.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# benchmark, comparing reading of largish simple feature objects from WKB
22
WKB_LINESTRING = function(m = 1, n) {
3-
stopifnot(m > 0 && n > 1)
3+
stopifnot(m > 0, n > 1)
44
l = lapply(seq_len(m), function(x) {
55
con = rawConnection(raw(0), "w")
66
writeBin(as.raw(1), con) # "little"

0 commit comments

Comments
 (0)