Skip to content

Instantly share code, notes, and snippets.

@naranjja
Last active October 4, 2019 03:17
Show Gist options
  • Save naranjja/cc545b0479117e17bde0606f924e5e18 to your computer and use it in GitHub Desktop.
Save naranjja/cc545b0479117e17bde0606f924e5e18 to your computer and use it in GitHub Desktop.
How to lint R project
linters: with_defaults(
line_length_linter(120),
camel_case_linter = NULL
)
if (suppressMessages(!require("pacman"))) install.packages("pacman", repos="https://mirror.cedia.org.ec/CRAN/")
pacman::p_load(lintr, styler)
# find all files that end with .R that are not lint.R
files_to_lint <- grep("(?<!lint)\\.R", list.files(), perl=T, value=T, ignore.case=T)
cat("Will lint these files:\n"); print(files_to_lint); cat("\n")
# properly style them
style_file(files_to_lint)
# lint each file and print output to console
cat("\nLinting", length(files_to_lint), "files:\n")
for (filename in files_to_lint) {
print(lint(filename))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment