lintr
provides static code
analysis for R. It checks for adherence to a given style,
identifying syntax errors and possible semantic issues, then reports
them to you so you can take action. Watch lintr in action in the
following animation:
lintr
is complementary to the styler
package which automatically restyles code, eliminating some of the
problems that lintr
can detect.
Install the stable version from CRAN:
install.packages("lintr")
Or the development version from GitHub:
::install_github("r-lib/lintr") devtools
# in a project:
::use_lintr(type = "tidyverse")
lintr::use_github_action("lint-project")
usethis::lint_dir()
lintr
# in a package:
::use_lintr(type = "tidyverse")
lintr::use_github_action("lint")
usethis::lint_package() lintr
You can also run lintr during continuous integration or within your
IDE or text editor. See vignette("continuous-integration")
and vignette("editors")
for more details.
Without further configuration, this will run the default
linters. See vignette("lintr")
to learn how to modify
these defaults.