-
Notifications
You must be signed in to change notification settings - Fork 6
/
check-has-contrib.R
51 lines (42 loc) · 1.36 KB
/
check-has-contrib.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#' Check whether package has contributor guidelines in a 'contributing' file.
#'
#' A "contributing" file is required for all rOpenSci packages, as documented
#' [in our "*Contributing
#' Guide*](https://devguide.ropensci.org/maintenance_collaboration.html#contributing-guide).
#'
#' @param checks A 'pkgcheck' object with full \pkg{pkgstats} summary and
#' \pkg{goodpractice} results.
#' @return Logical flag
#' @noRd
pkgchk_has_contrib_md <- function (checks) {
flist <- list.files (
checks$pkg$path,
all.files = TRUE,
recursive = TRUE,
full.names = FALSE
)
# remove any renv files (#141). The 'pattern' param of
# flist only works as positive filter.
ptn <- paste0 (.Platform$file.sep, "renv", .Platform$file.sep)
flist <- flist [which (!grepl (ptn, flist))]
flist <- vapply (flist, function (i) {
utils::tail (decompose_path (i) [[1]], 1L)
},
character (1),
USE.NAMES = FALSE
)
chk <- any (grepl ("^contributing(\\.|$)", flist, ignore.case = TRUE))
return (chk)
}
output_pkgchk_has_contrib <- function (checks) {
out <- list (
check_pass = checks$checks$has_contrib,
summary = "",
print = ""
) # no print method
out$summary <- paste0 (
ifelse (out$check_pass, "has", "does not have"),
" a 'contributing' file."
)
return (out)
}