unnecessary_concatenation_linter {lintr} | R Documentation |
Unneeded concatenation linter
Description
Check that the c()
function is not used without arguments nor with a single constant.
Usage
unnecessary_concatenation_linter(allow_single_expression = TRUE)
Arguments
allow_single_expression |
Logical, default |
Tags
configurable, efficiency, readability, style
See Also
linters for a complete list of linters available in lintr.
Examples
# will produce lints
lint(
text = "x <- c()",
linters = unnecessary_concatenation_linter()
)
lint(
text = "x <- c(TRUE)",
linters = unnecessary_concatenation_linter()
)
lint(
text = "x <- c(1.5 + 2.5)",
linters = unnecessary_concatenation_linter(allow_single_expression = FALSE)
)
# okay
lint(
text = "x <- NULL",
linters = unnecessary_concatenation_linter()
)
# In case the intent here was to seed a vector of known size
lint(
text = "x <- integer(4L)",
linters = unnecessary_concatenation_linter()
)
lint(
text = "x <- TRUE",
linters = unnecessary_concatenation_linter()
)
lint(
text = "x <- c(1.5 + 2.5)",
linters = unnecessary_concatenation_linter(allow_single_expression = TRUE)
)
[Package lintr version 3.1.2 Index]