View source: R/unnecessary_concatenation_linter.R
unnecessary_concatenation_linter | R Documentation |
Check that the c()
function is not used without arguments nor with a single constant.
unnecessary_concatenation_linter(allow_single_expression = TRUE)
allow_single_expression |
Logical, default |
configurable, efficiency, readability, style
linters for a complete list of linters available in lintr.
# 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)
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.