lint | R Documentation |
lint()
lints a single file.
lint_dir()
lints all files in a directory.
lint_package()
lints all likely locations for R files in a package, i.e.
R/
, tests/
, inst/
, vignettes/
, data-raw/
, demo/
, and exec/
.
lint(
filename,
linters = NULL,
...,
cache = FALSE,
parse_settings = TRUE,
text = NULL
)
lint_dir(
path = ".",
...,
relative_path = TRUE,
exclusions = list("renv", "packrat"),
pattern = "(?i)[.](r|rmd|qmd|rnw|rhtml|rrst|rtex|rtxt)$",
parse_settings = TRUE,
show_progress = NULL
)
lint_package(
path = ".",
...,
relative_path = TRUE,
exclusions = list("R/RcppExports.R"),
parse_settings = TRUE,
show_progress = NULL
)
filename |
Either the filename for a file to lint, or a character string of inline R code for linting.
The latter (inline data) applies whenever |
linters |
A named list of linter functions to apply. See linters for a full list of default and available linters. |
... |
Provide additional arguments to be passed to:
|
cache |
When logical, toggle caching of lint results. If passed a character string, store the cache in this directory. |
parse_settings |
Logical, default |
text |
Optional argument for supplying a string or lines directly, e.g. if the file is already in memory or linting is being done ad hoc. |
path |
For the base directory of the project (for |
relative_path |
if |
exclusions |
exclusions for |
pattern |
pattern for files, by default it will take files with any of the extensions .R, .Rmd, .qmd, .Rnw, .Rhtml, .Rrst, .Rtex, .Rtxt allowing for lowercase r (.r, ...). |
show_progress |
Logical controlling whether to show linting progress with a simple text
progress bar via |
Read vignette("lintr")
to learn how to configure which linters are run
by default.
Note that if files contain unparseable encoding problems, only the encoding problem will be linted to avoid
unintelligible error messages from other linters.
An object of class c("lints", "list")
, each element of which is a "list"
object.
# linting inline-code
lint("a = 123\n")
lint(text = "a = 123")
# linting a file
f <- tempfile()
writeLines("a=1", f)
lint(f)
unlink(f)
if (FALSE) {
lint_dir()
lint_dir(
linters = list(semicolon_linter()),
exclusions = list(
"inst/doc/creating_linters.R" = 1,
"inst/example/bad.R",
"renv"
)
)
}
if (FALSE) {
lint_package()
lint_package(
linters = linters_with_defaults(semicolon_linter = semicolon_linter()),
exclusions = list("inst/doc/creating_linters.R" = 1, "inst/example/bad.R")
)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.