Skip to content
This repository has been archived by the owner on May 10, 2022. It is now read-only.

Commit

Permalink
Add helper function to check preferred packages
Browse files Browse the repository at this point in the history
  • Loading branch information
noamross committed May 26, 2017
1 parent 3a90bc1 commit f3b8bf3
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 2 deletions.
4 changes: 3 additions & 1 deletion NAMESPACE
Expand Up @@ -2,9 +2,11 @@

export(check_version_control)
export(check_well_commented)
export(prep_lint_dir)
export(gp_check)
export(load_config)
export(make_pref_pkg_check)
export(prep_lint_dir)
export(prep_packages)
export(prep_scripts)
export(prep_version_control)
importFrom(goodpractice,all_checks)
Expand Down
27 changes: 27 additions & 0 deletions R/check_packages.R
@@ -0,0 +1,27 @@
# check_xml <- make_pref_pkg_check("XML", "xml2")
# goodpractice::gp("inst/scripts", checks="XML", extra_preps=list(packages=prep_packages), extra_checks = list(XML = check_xml))
#' @export
prep_packages = make_prep("packages", function(path, quiet) {
packrat:::dirDependencies(path)
})

#' @export
make_pref_pkg_check <- function(unfavored, favored) {

make_check(
description = paste0(unfavored,
" is an unfavored package"),
tags = character(0),
preps = c("packages"),

gp = function(state) {
paste0(
"Use preferred packages. You are using ", unfavored,
". Preferred alternatives are: ",
paste0(favored, collapse = ", "), ".")
},
check = function(state) {
!(unfavored %in% state$packages)
}
)
}
2 changes: 1 addition & 1 deletion R/check_version_control.R
Expand Up @@ -34,7 +34,7 @@ check_version_control <- make_check(
preps = c("version_control"),
gp = function(state) {
paste0(
"Place your project under version control.",
"Place your project under version control. ",
"You are using neither git nor svn. See http://happygitwithr.com/ for more info"
)
},
Expand Down
1 change: 1 addition & 0 deletions checkers.Rproj
Expand Up @@ -3,6 +3,7 @@ Version: 1.0
RestoreWorkspace: Default
SaveWorkspace: Default
AlwaysSaveHistory: Default
QuitChildProcessesOnExit: Default

EnableCodeIndexing: Yes
UseSpacesForTab: Yes
Expand Down

0 comments on commit f3b8bf3

Please sign in to comment.