Last active
October 4, 2019 03:17
-
-
Save naranjja/cc545b0479117e17bde0606f924e5e18 to your computer and use it in GitHub Desktop.
How to lint R project
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
linters: with_defaults( | |
line_length_linter(120), | |
camel_case_linter = NULL | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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