Function left parentheses linter
Source:R/function_left_parentheses_linter.R
function_left_parentheses_linter.Rd
Check that all left parentheses in a function call do not have spaces before them
(e.g. mean (1:3)
). Although this is syntactically valid, it makes the code
difficult to read.
See also
linters for a complete list of linters available in lintr.
Examples
# will produce lints
lint(
text = "mean (x)",
linters = function_left_parentheses_linter()
)
#> <text>:1:5: style: [function_left_parentheses_linter] Remove spaces before the left parenthesis in a function call.
#> mean (x)
#> ^
lint(
text = "stats::sd(c (x, y, z))",
linters = function_left_parentheses_linter()
)
#> <text>:1:12: style: [function_left_parentheses_linter] Remove spaces before the left parenthesis in a function call.
#> stats::sd(c (x, y, z))
#> ^
# okay
lint(
text = "mean(x)",
linters = function_left_parentheses_linter()
)
#> ℹ No lints found.
lint(
text = "stats::sd(c(x, y, z))",
linters = function_left_parentheses_linter()
)
#> ℹ No lints found.
lint(
text = "foo <- function(x) (x + 1)",
linters = function_left_parentheses_linter()
)
#> ℹ No lints found.