Skip to content

Commit

Permalink
Fix lint warnings with new lintr
Browse files Browse the repository at this point in the history
A new modification of brace_lintr was added in lintr 3.0.0;
unfortunately this is not configurable without entirely disabling
the linter which does other desirable things entirely.

See

r-lib/lintr#987 (introduces new linter)
r-lib/lintr#1092 (combines linters unconfigurably)
  • Loading branch information
richfitz committed Jul 27, 2022
1 parent cb01a4a commit aa7a85f
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 28 deletions.
3 changes: 1 addition & 2 deletions .lintr
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
linters: with_defaults(
linters: linters_with_defaults(
object_length_linter = NULL,
object_usage_linter = NULL,
todo_comment_linter = NULL,
cyclocomp_linter = NULL
)
exclusions: list("tests/testthat.R", "R/cpp11.R")
5 changes: 3 additions & 2 deletions R/config.R
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,9 @@ config_serialise <- function(config, path) {
c(lapply(loc[setdiff(names(loc), "args")], scalar),
list(args = lapply(loc$args[[1]], scalar)))
}
config$location <- lapply(seq_len(nrow(config$location)), function(i)
prepare_location(config$location[i, ]))
config$location <- lapply(seq_len(nrow(config$location)), function(i) {
prepare_location(config$location[i, ])
})

to_json(config, "config")
}
Expand Down
5 changes: 3 additions & 2 deletions R/metadata.R
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,10 @@ outpack_metadata_load <- function(json) {
hash = vcapply(data$files, "[[", "hash"))
data$depends <- data_frame(
id = vcapply(data$depends, "[[", "id"),
files = I(lapply(data$depends, function(x)
files = I(lapply(data$depends, function(x) {
data_frame(here = vcapply(x$files, "[[", "here"),
there = vcapply(x$files, "[[", "there")))))
there = vcapply(x$files, "[[", "there"))
})))

data
}
Expand Down
10 changes: 6 additions & 4 deletions R/packet.R
Original file line number Diff line number Diff line change
Expand Up @@ -253,14 +253,16 @@ outpack_packet_add_custom <- function(application, data, schema = NULL) {

tryCatch(
jsonlite::parse_json(data),
error = function(e)
stop("Syntax error in custom metadata: ", e$message, call. = FALSE))
error = function(e) {
stop("Syntax error in custom metadata: ", e$message, call. = FALSE)
})

if (should_validate_schema(schema)) {
tryCatch(
custom_schema(schema)$validate(data, error = TRUE),
error = function(e)
stop("Validating custom metadata failed: ", e$message, call. = FALSE))
error = function(e) {
stop("Validating custom metadata failed: ", e$message, call. = FALSE)
})
}

if (application %in% vcapply(p$custom, "[[", "application")) {
Expand Down
5 changes: 3 additions & 2 deletions R/parameters.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ validate_parameters <- function(parameters) {
assert_named(parameters, unique = TRUE)
## NOTE: technically this allows raw and complex through, which is a
## bit undesirable but unlikely
ok <- vlapply(parameters, function(x)
length(x) == 1 && is.atomic(x) && !is.na(x))
ok <- vlapply(parameters, function(x) {
length(x) == 1 && is.atomic(x) && !is.na(x)
})
if (!all(ok)) {
stop(sprintf("All parameters must be scalar atomics: error for %s",
paste(squote(names(parameters)[!ok]), collapse = ", ")))
Expand Down
28 changes: 12 additions & 16 deletions tests/testthat/test-query.R
Original file line number Diff line number Diff line change
Expand Up @@ -147,14 +147,10 @@ test_that("Scope queries", {
on.exit(unlink(tmp, recursive = TRUE))
root <- outpack_init(tmp, use_file_store = TRUE)

x1 <- vcapply(1:3, function(i)
create_random_packet(tmp, "x", list(a = 1)))
x2 <- vcapply(1:3, function(i)
create_random_packet(tmp, "x", list(a = 2)))
y1 <- vcapply(1:3, function(i)
create_random_packet(tmp, "y", list(a = 1)))
y2 <- vcapply(1:3, function(i)
create_random_packet(tmp, "y", list(a = 2)))
x1 <- vcapply(1:3, function(i) create_random_packet(tmp, "x", list(a = 1)))
x2 <- vcapply(1:3, function(i) create_random_packet(tmp, "x", list(a = 2)))
y1 <- vcapply(1:3, function(i) create_random_packet(tmp, "y", list(a = 1)))
y2 <- vcapply(1:3, function(i) create_random_packet(tmp, "y", list(a = 2)))

expect_equal(
outpack_query(quote(parameter:a == 1), root = root),
Expand All @@ -180,8 +176,9 @@ test_that("location based queries", {

ids <- list()
for (name in c("x", "y", "z")) {
ids[[name]] <- vcapply(1:3, function(i)
create_random_packet(root[[name]], "data", list(p = i)))
ids[[name]] <- vcapply(1:3, function(i) {
create_random_packet(root[[name]], "data", list(p = i))
})
}
outpack_location_pull_metadata(root = path$a)

Expand All @@ -205,10 +202,8 @@ test_that("Can filter based on given values", {
on.exit(unlink(tmp, recursive = TRUE))
root <- outpack_init(tmp, use_file_store = TRUE)

x1 <- vcapply(1:3, function(i)
create_random_packet(tmp, "x", list(a = 1)))
x2 <- vcapply(1:3, function(i)
create_random_packet(tmp, "x", list(a = 2)))
x1 <- vcapply(1:3, function(i) create_random_packet(tmp, "x", list(a = 1)))
x2 <- vcapply(1:3, function(i) create_random_packet(tmp, "x", list(a = 2)))

expect_equal(
outpack_query(quote(latest(parameter:a == this:a)),
Expand Down Expand Up @@ -285,8 +280,9 @@ test_that("Can filter query to packets that are locally available (unpacked)", {

ids <- list()
for (name in c("x", "y", "z")) {
ids[[name]] <- vcapply(1:3, function(i)
create_random_packet(root[[name]], "data", list(p = i)))
ids[[name]] <- vcapply(1:3, function(i) {
create_random_packet(root[[name]], "data", list(p = i))
})
}
outpack_location_pull_metadata(root = path$a)

Expand Down

0 comments on commit aa7a85f

Please sign in to comment.