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

Commit

Permalink
if this than that
Browse files Browse the repository at this point in the history
  • Loading branch information
ldecicco-USGS committed May 27, 2017
1 parent 4aa9adb commit d1fdf6a
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 8 deletions.
24 changes: 20 additions & 4 deletions R/all_check_prep.R
Expand Up @@ -9,8 +9,15 @@ all_checkers <- function(){
main_defaults <- c(main_defaults, options()$checkers[["goodpractice"]])
}

if(length(options()$checkers[["make_pref_pkg_check"]]) > 0){
main_defaults <- c(main_defaults, names(options()$checkers[["make_pref_pkg_check"]]))
pref_list <- options()$checkers[["make_pref_pkg_check"]]
if_then_list <- options()$checkers[["if_this_than_that"]]

if(length(pref_list) > 0){
main_defaults <- c(main_defaults, names(pref_list))
}

if(length(if_then_list) > 0){
main_defaults <- c(main_defaults, names(if_then_list))
}

return(main_defaults)
Expand All @@ -24,19 +31,27 @@ all_extra_checkers <- function(){
"version_control"=check_version_control)

pref_list <- options()$checkers[["make_pref_pkg_check"]]
if_then_list <- options()$checkers[["if_this_than_that"]]

if(length(pref_list) > 0){

for(i in names(pref_list)){
favored <- pref_list[[i]]$favored
unfavored <- pref_list[[i]]$unfavored
check_fun <- make_pref_pkg_check(favored = favored,
unfavored = unfavored)
main_defaults[[i]] <- check_fun
}

}

if(length(if_then_list) > 0){
for(i in names(if_then_list)){
if_this <- if_then_list[[i]]$if_this
needs_that <- if_then_list[[i]]$needs_that
check_fun <- make_fun_pair_check(fun1 = if_this,
fun2 = needs_that)
main_defaults[[i]] <- check_fun
}
}
return(main_defaults)
}

Expand All @@ -46,6 +61,7 @@ all_extra_checkers <- function(){
all_prepers <- function(){
return(list("scripts" = prep_scripts,
"version_control" = prep_version_control,
"functions" = prep_functions,
"lintr" = prep_lint_dir,
"packages" = prep_packages))
}
6 changes: 4 additions & 2 deletions inst/extdata/default.yaml
@@ -1,4 +1,3 @@
package: "assertthat" #using this package?
goodpractice:
["lintr_assignment_linter",
"lintr_line_length_linter",
Expand All @@ -15,5 +14,8 @@ make_pref_pkg_check:
JSON:
favored: jsonlite
unfavored: rjson
if_this_than_that: ["gam","gam.check"] #if gam than gam.check
if_this_than_that:
gam:
if_this: gam
needs_that: gam.check
comment_threshold: 0.05
11 changes: 9 additions & 2 deletions tests/testthat/test.R
Expand Up @@ -29,11 +29,18 @@ test_that("checkers works", {
expect_type(check_results, "list")

check_xml <- make_pref_pkg_check("XML", "xml2")
gp_check(path=system.file("scripts", package="checkers"),
pref_package <- gp_check(path=system.file("scripts", package="checkers"),
checks="XML",
extra_preps=list(packages=prep_packages),
extra_checks = list(XML = check_xml))

expect_type(pref_package, "list")

check_gam <- make_fun_pair_check("gam", "gam.check")
check_funs <- gp_check(path=system.file("scripts", package="checkers"),
checks = "check_gam",
extra_preps = list(functions = prep_functions),
extra_checks = list(check_gam = check_gam))
expect_type(check_funs, "list")
})


Expand Down

0 comments on commit d1fdf6a

Please sign in to comment.