Debian Codegraph @

R/check.R

raw
1
2 renv_check_unknown_source <- function(records, project = NULL) {
3
4 # nothing to do if we have no records
5 if (empty(records))
6 return(TRUE)
7
8 # for testing, we ignore renv
9 if (renv_tests_running())
10 records$renv <- NULL
11
12 # keep only records which have unknown source
13 unknown <- filter(records, function(record) {
14
15 source <- renv_record_source(record)
16 if (source != "unknown")
17 return(FALSE)
18
19 localpath <- tryCatch(
20 renv_retrieve_cellar_find(record, project),
21 error = function(e) ""
22 )
23
24 if (file.exists(localpath))
25 return(FALSE)
26
27 TRUE
28
29 })
30
31 # if all records have a known source, return TRUE
32 if (empty(unknown))
33 return(TRUE)
34
35 # provide warning
36 if (!renv_tests_running())
37 renv_warnings_unknown_sources(unknown)
38
39 # return FALSE to indicate failed validation
40 FALSE
41
42 }
43
44