commas_linter: Commas linter

View source: R/commas_linter.R

commas_linterR Documentation

Commas linter

Description

Check that all commas are followed by spaces, but do not have spaces before them.

Usage

commas_linter(allow_trailing = FALSE)

Arguments

allow_trailing

If TRUE, the linter allows a comma to be followed directly by a closing bracket without a space.

Tags

configurable, default, readability, style

See Also

Examples

# will produce lints
lint(
  text = "switch(op , x = foo, y = bar)",
  linters = commas_linter()
)

lint(
  text = "mean(x,trim = 0.2,na.rm = TRUE)",
  linters = commas_linter()
)

lint(
  text = "x[ ,, drop=TRUE]",
  linters = commas_linter()
)

lint(
  text = "x[1,]",
  linters = commas_linter()
)

# okay
lint(
  text = "switch(op, x = foo, y = bar)",
  linters = commas_linter()
)

lint(
  text = "switch(op, x = , y = bar)",
  linters = commas_linter()
)

lint(
  text = "mean(x, trim = 0.2, na.rm = TRUE)",
  linters = commas_linter()
)

lint(
  text = "a[1, , 2, , 3]",
  linters = commas_linter()
)

lint(
  text = "x[1,]",
  linters = commas_linter(allow_trailing = TRUE)
)


r-lib/lintr documentation built on Dec. 20, 2024, 7:24 p.m.