Learn R Programming

lintr (version 3.1.0)

implicit_assignment_linter: Avoid implicit assignment in function calls

Description

Assigning inside function calls makes the code difficult to read, and should be avoided, except for functions that capture side-effects (e.g. capture.output()).

Usage

implicit_assignment_linter(
  except = c("bquote", "expression", "expr", "quo", "quos", "quote")
)

Arguments

except

A character vector of functions to be excluded from linting.

Tags

best_practices, configurable, readability, style

See Also

Examples

Run this code
# will produce lints
lint(
  text = "if (x <- 1L) TRUE",
  linters = implicit_assignment_linter()
)

lint(
  text = "mean(x <- 1:4)",
  linters = implicit_assignment_linter()
)

# okay
writeLines("x <- 1L\nif (x) TRUE")
lint(
  text = "x <- 1L\nif (x) TRUE",
  linters = implicit_assignment_linter()
)

writeLines("x <- 1:4\nmean(x)")
lint(
  text = "x <- 1:4\nmean(x)",
  linters = implicit_assignment_linter()
)

Run the code above in your browser using DataLab