View source: R/infix_spaces_linter.R
infix_spaces_linter | R Documentation |
Check that infix operators are surrounded by spaces. Enforces the corresponding Tidyverse style guide rule; see https://style.tidyverse.org/syntax.html#infix-operators.
infix_spaces_linter(exclude_operators = NULL, allow_multiple_spaces = TRUE)
exclude_operators |
Character vector of operators to exclude from consideration for linting.
Default is to include the following "low-precedence" operators:
|
allow_multiple_spaces |
Logical, default |
configurable, default, readability, style
linters for a complete list of linters available in lintr.
# will produce lints
lint(
text = "x<-1L",
linters = infix_spaces_linter()
)
lint(
text = "1:4 %>%sum()",
linters = infix_spaces_linter()
)
# okay
lint(
text = "x <- 1L",
linters = infix_spaces_linter()
)
lint(
text = "1:4 %>% sum()",
linters = infix_spaces_linter()
)
code_lines <- "
ab <- 1L
abcdef <- 2L
"
writeLines(code_lines)
lint(
text = code_lines,
linters = infix_spaces_linter(allow_multiple_spaces = TRUE)
)
lint(
text = "a||b",
linters = infix_spaces_linter(exclude_operators = "||")
)
lint(
text = "sum(1:10, na.rm=TRUE)",
linters = infix_spaces_linter(exclude_operators = "EQ_SUB")
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.