Check that there is no commented code outside roxygen blocks.
See also
linters for a complete list of linters available in lintr.
Examples
# will produce lints
lint(
text = "# x <- 1",
linters = commented_code_linter()
)
#> <text>:1:3: style: [commented_code_linter] Remove commented code.
#> # x <- 1
#> ^~~~~~
lint(
text = "x <- f() # g()",
linters = commented_code_linter()
)
#> <text>:1:12: style: [commented_code_linter] Remove commented code.
#> x <- f() # g()
#> ^~~
lint(
text = "x + y # + z[1, 2]",
linters = commented_code_linter()
)
#> <text>:1:9: style: [commented_code_linter] Remove commented code.
#> x + y # + z[1, 2]
#> ^~~~~~~~~
# okay
lint(
text = "x <- 1; x <- f(); x + y",
linters = commented_code_linter()
)
#> ℹ No lints found.
lint(
text = "#' x <- 1",
linters = commented_code_linter()
)
#> ℹ No lints found.