# will produce lints
lint(
text = "if (x <- 1L) TRUE",
linters = implicit_assignment_linter()
)
lint(
text = "mean(x <- 1:4)",
linters = implicit_assignment_linter()
)
# okay
lines <- "x <- 1L\nif (x) TRUE"
writeLines(lines)
lint(
text = lines,
linters = implicit_assignment_linter()
)
lines <- "x <- 1:4\nmean(x)"
writeLines(lines)
lint(
text = lines,
linters = implicit_assignment_linter()
)
lint(
text = "A && (B <- foo(A))",
linters = implicit_assignment_linter(allow_lazy = TRUE)
)
lines <- c(
"if (any(idx <- x < 0)) {",
" stop('negative elements: ', toString(which(idx)))",
"}"
)
writeLines(lines)
lint(
text = lines,
linters = implicit_assignment_linter(allow_scoped = TRUE)
)
Run the code above in your browser using DataLab