Check that no semicolons terminate expressions.
See also
linters for a complete list of linters available in lintr.
Examples
# will produce lints
lint(
text = "a <- 1;",
linters = semicolon_linter()
)
#> <text>:1:7: style: [semicolon_linter] Remove trailing semicolons.
#> a <- 1;
#> ^
lint(
text = "a <- 1; b <- 1",
linters = semicolon_linter()
)
#> <text>:1:7: style: [semicolon_linter] Replace compound semicolons by a newline.
#> a <- 1; b <- 1
#> ^
lint(
text = "function() { a <- 1; b <- 1 }",
linters = semicolon_linter()
)
#> <text>:1:20: style: [semicolon_linter] Replace compound semicolons by a newline.
#> function() { a <- 1; b <- 1 }
#> ^
# okay
lint(
text = "a <- 1",
linters = semicolon_linter()
)
#> ℹ No lints found.
lint(
text = "a <- 1;",
linters = semicolon_linter(allow_trailing = TRUE)
)
#> ℹ No lints found.
code_lines <- "a <- 1\nb <- 1"
writeLines(code_lines)
#> a <- 1
#> b <- 1
lint(
text = code_lines,
linters = semicolon_linter()
)
#> ℹ No lints found.
lint(
text = "a <- 1; b <- 1",
linters = semicolon_linter(allow_compound = TRUE)
)
#> ℹ No lints found.
code_lines <- "function() { \n a <- 1\n b <- 1\n}"
writeLines(code_lines)
#> function() {
#> a <- 1
#> b <- 1
#> }
lint(
text = code_lines,
linters = semicolon_linter()
)
#> ℹ No lints found.