Skip to content

Commit 2ab9f46

Browse files
authored
Merge pull request #137 from ropensci-review-tools/vignette
chaoss metrics vignette for #124
2 parents 19ed0fc + dc06117 commit 2ab9f46

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+874
-236
lines changed

.pre-commit-config.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ repos:
55
rev: v0.4.3.9003
66
hooks:
77
- id: style-files
8-
args: [--style_pkg=spaceout, --style_fun=spaceout_style]
8+
args: [--style_pkg=spaceout, --style_fun=spaceout_style, --include_roxygen_examples=FALSE]
99
additional_dependencies:
1010
- ropensci-review-tools/spaceout
1111
# - id: roxygenize

DESCRIPTION

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: repometrics
22
Title: Metrics for Your Code Repository
3-
Version: 0.1.6.132
3+
Version: 0.1.6.145
44
Authors@R:
55
person("Mark", "Padgham", , "[email protected]", role = c("aut", "cre"),
66
comment = c(ORCID = "0000-0003-2172-5265"))
@@ -26,6 +26,7 @@ Imports:
2626
Suggests:
2727
brio,
2828
desc,
29+
DT,
2930
httptest2,
3031
jsonlite,
3132
knitr,

NAMESPACE

+1
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@ export(repometrics_dashboard)
55
export(repometrics_data)
66
export(repometrics_data_repo)
77
export(repometrics_data_user)
8+
export(rm_chaoss_metrics_list)
89
importFrom(memoise,memoise)

R/cm-collate-all.R

+42-5
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,51 @@
1-
get_cm_fns <- function (what = "metric") {
1+
#' List all implemented CHAOSS metrics
2+
#'
3+
#' This function returns a list of internal functions defined within the
4+
#' 'repometrics' package. These internal functions are not intended to be
5+
#' called directly, rather this list is provided for information only, to
6+
#' enable users to know which metrics are implemented.
7+
#'
8+
#' @return A `data.frame` with two columns:
9+
#' \enumerate{
10+
#' \item "fn_names", with the internal function names of all implemented CHAOSS
11+
#' metrics.
12+
#' \item "url", with the URL to the CHAOSS community web page describing that
13+
#' metric.
14+
#' }
15+
#'
16+
#' @note Metrics have been adapted in this package, and so may not precisely
17+
#' reflect the descriptions provided in the CHAOSS community web pages linked
18+
#' to in the URLs from this function. Adaptations have in particular been
19+
#' implemented to align metrics with their usage in aggregate "models".
20+
#'
21+
#' @examples
22+
#' metrics <- rm_chaoss_metrics_list ()
23+
#' @family auxiliary
24+
#' @export
25+
rm_chaoss_metrics_list <- function () {
26+
27+
fn_names <- chaoss_metrics_fn_names ()
28+
url_fns <- paste0 (fn_names, "_url")
29+
urls <- vapply (url_fns, function (u) do.call (u, list ()), character (1L))
30+
urls <- paste0 (cm_metric_base_url (), unname (urls))
31+
32+
data.frame (fn_name = fn_names, url = urls)
33+
}
234

3-
what <- match.arg (what, c ("metric", "model"))
4-
ptn <- paste0 ("^cm\\_", what, "\\_")
35+
chaoss_metrics_fn_names <- function () {
536

37+
ptn <- "^cm\\_metric\\_"
638
pkg_fns <- ls (envir = asNamespace ("repometrics"))
739
fns <- grep (ptn, pkg_fns, value = TRUE)
8-
fns <- fns [which (!grepl ("internal", fns))]
40+
fns <- fns [which (!grepl ("\\_internal|\\_url$", fns))]
941

1042
return (fns)
43+
1144
}
1245

1346
collate_all_metrics <- function (path, end_date = Sys.Date ()) {
1447

15-
metric_fns <- get_cm_fns ("metric")
48+
metric_fns <- rm_chaoss_metrics_list ()$fn_name
1649

1750
pars <- list (path = path, end_date = end_date)
1851
extra_pars <- list (
@@ -84,3 +117,7 @@ models_over_end_dates <- function (path, end_date = Sys.Date (), num_years = 3)
84117

85118
return (models_data)
86119
}
120+
121+
cm_metric_base_url <- function () {
122+
"https://chaoss.community/kb/"
123+
}

R/cm-metric-best-practices.R

+4-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
#' This extends beyond the single CHAOSS recommendation of OpenSSF to also
44
#' include the core infrastructure best practices badge.
55
#'
6-
#' \url{https://chaoss.community/kb/metric-open-source-security-foundation-openssf-best-practices-badge/}
7-
#'
86
#' This metric does not use the `end_date` parameter (but includes it to
97
#' provide a consistent interface).
108
#'
@@ -25,3 +23,7 @@ cm_data_best_practices <- function (path, end_date = NULL) {
2523
cm_metric_best_practices <- function (path, end_date = NULL) {
2624
cm_data_best_practices (path, end_date)
2725
}
26+
27+
cm_metric_best_practices_url <- function () {
28+
"metric-open-source-security-foundation-openssf-best-practices-badge"
29+
}

R/cm-metric-burstiness.R

+4
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,7 @@ cm_data_burstiness <- function (path, end_date, band_len = 31L, band_width = 2)
6161
cm_metric_burstiness <- function (path, end_date, band_len = 31L, band_width = 2) {
6262
cm_data_burstiness (path, end_date, band_len = 31L, band_width = 2)
6363
}
64+
65+
cm_metric_burstiness_url <- function () {
66+
"metric-burstiness"
67+
}

R/cm-metric-change-req.R

+16
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,19 @@ cm_metric_change_req_prop_code <- function (path, end_date = Sys.Date ()) {
6464
dat <- cm_data_change_req (path, end_date)
6565
dat [["prop_code_from_prs"]]
6666
}
67+
68+
cm_metric_change_req_n_opened_url <- function () {
69+
"metric-change-requests"
70+
}
71+
72+
cm_metric_change_req_n_closed_url <- function () {
73+
"metric-change-requests"
74+
}
75+
76+
cm_metric_change_req_prop_merged_url <- function () {
77+
"metric-change-requests"
78+
}
79+
80+
cm_metric_change_req_prop_code_url <- function () {
81+
"metric-change-requests"
82+
}

R/cm-metric-code-change.R

+4
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,7 @@ cm_metric_code_change_lines <- function (path,
1919

2020
cm_data_code_change_lines (path, end_date, exclude_whitespace)
2121
}
22+
23+
cm_metric_code_change_lines_url <- function () {
24+
"metric-code-changes-commits"
25+
}

R/cm-metric-cran-downloads.R

+4
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ cm_metric_cran_downloads <- function (path, end_date = Sys.Date ()) {
2424
cm_data_cran_downloads (path, end_date)
2525
}
2626

27+
cm_metric_cran_downloads_url <- function () {
28+
"metric-number-of-downloads"
29+
}
30+
2731
#' Download the full daily log over `nyears`, and use memoised return value to
2832
#' filter to desired period for subsequent calls.
2933
#' @noRd

R/cm-metric-ctb-absence.R

+4
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ cm_metric_contrib_absence_commits <- function (path, end_date = Sys.Date ()) {
2626
dat [["ncommits"]]
2727
}
2828

29+
cm_metric_contrib_absence_commits_url <- function () {
30+
"metric-contributor-absence-factor"
31+
}
32+
2933
# These others are not used, as they are highly correlated with main measure
3034
# anyway:
3135
#

R/cm-metric-ctb-count.R

+12
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ cm_metric_ctb_count <- function (path, end_date = Sys.Date ()) {
3636
return (dat [["code"]])
3737
}
3838

39+
cm_metric_ctb_count_url <- function () {
40+
"metrics-model-community-activity"
41+
}
42+
3943
#' CHAOSS metric for committer count
4044
#'
4145
#' \url{https://chaoss.community/kb/metric-committers/}.
@@ -87,3 +91,11 @@ cm_metric_watcher_count <- function (path, end_date = Sys.Date ()) {
8791
dat <- cm_data_committer_count (path, end_date)
8892
return (dat [["watchers"]])
8993
}
94+
95+
cm_metric_committer_count_url <- function () {
96+
"metrics-model-community-activity"
97+
}
98+
99+
cm_metric_watcher_count_url <- function () {
100+
"metrics-model-community-activity"
101+
}

R/cm-metric-ctb-types.R

+4
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,7 @@ cm_data_ctb_diversity <- function (path, end_date = Sys.Date ()) {
4343
cm_metric_ctb_diversity <- function (path, end_date = Sys.Date ()) {
4444
cm_data_ctb_diversity (path, end_date)
4545
}
46+
47+
cm_metric_ctb_diversity_url <- function () {
48+
"metric-types-of-contributions"
49+
}

R/cm-metric-elephant-factor.R

+4
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,7 @@ cm_metric_elephant_factor <- function (path, end_date = Sys.Date ()) {
4343
dat <- cm_data_elephant_factor (path, end_date)
4444
dat [["ncommits"]]
4545
}
46+
47+
cm_metric_elephant_factor_url <- function () {
48+
"metric-elephant-factor"
49+
}

R/cm-metric-has-ci.R

+4
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,7 @@ cm_data_has_ci <- function (path, end_date = NULL) {
5050
cm_metric_has_ci <- function (path, end_date = NULL) {
5151
cm_data_has_ci (path, end_date)
5252
}
53+
54+
cm_metric_has_ci_url <- function () {
55+
"metric-test-coverage"
56+
}

R/cm-metric-issue-updates.R

+12
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ cm_metric_issue_updates <- function (path, end_date = Sys.Date ()) {
2525
cm_data_issue_updates (path, end_date)
2626
}
2727

28+
cm_metric_issue_updates_url <- function () {
29+
"metric-issues-active"
30+
}
31+
2832
cm_data_issue_cmt_count <- function (path, end_date = Sys.Date ()) {
2933

3034
# Suppress no visible binding note:
@@ -56,6 +60,10 @@ cm_metric_issue_cmt_count <- function (path, end_date = Sys.Date ()) {
5660
cm_data_issue_cmt_count (path, end_date) [["mean"]]
5761
}
5862

63+
cm_metric_issue_cmt_count_url <- function () {
64+
"metric-issues-active"
65+
}
66+
5967
cm_data_issues_closed <- function (path, end_date = Sys.Date ()) {
6068

6169
# Suppress no visible binding note:
@@ -74,3 +82,7 @@ cm_data_issues_closed <- function (path, end_date = Sys.Date ()) {
7482
cm_metric_issues_closed <- function (path, end_date = Sys.Date ()) {
7583
cm_data_issues_closed (path, end_date)
7684
}
85+
86+
cm_metric_issues_closed_url <- function () {
87+
"metric-issues-closed"
88+
}

R/cm-metric-issues-to-prs.R

+4
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ cm_metric_issues_to_prs <- function (path, end_date = Sys.Date ()) {
1515
cm_data_issues_to_prs (path, end_date)
1616
}
1717

18+
cm_metric_issues_to_prs_url <- function () {
19+
"metric-change-requests"
20+
}
21+
1822
get_issues_in_period <- function (path,
1923
end_date = Sys.Date (),
2024
closed_only = FALSE) {

R/cm-metric-labels.R

+4
Original file line numberDiff line numberDiff line change
@@ -58,3 +58,7 @@ cm_metric_label_inclusivity <- function (path, end_date = Sys.Date ()) {
5858
dat <- cm_data_label_inclusivity (path, end_date)
5959
return (dat [["prop_friendly_overall"]])
6060
}
61+
62+
cm_metric_label_inclusivity_url <- function () {
63+
"chaoss.community/kb/metric-issue-label-inclusivity"
64+
}

R/cm-metric-languages.R

+4
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,7 @@ cm_metric_languages <- function (path, end_date = NULL) {
5050
lang_dist_mn <- ifelse (lang_dist_mn == 0, 0, 0.25 / lang_dist_mn)
5151
return (lang_dist_mn)
5252
}
53+
54+
cm_metric_languages_url <- function () {
55+
"chaoss.community/?p=3430"
56+
}

R/cm-metric-libyears.R

+8
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,11 @@ cm_metric_dependency_count <- function (path, end_date = NULL) {
2525

2626
return (nrow (deps))
2727
}
28+
29+
cm_metric_libyears_url <- function () {
30+
"chaoss.community/kb/metric-libyears"
31+
}
32+
33+
cm_metric_dependency_count_url <- function () {
34+
"chaoss.community/kb/metric-libyears"
35+
}

R/cm-metric-licenses.R

+8
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ cm_metric_licenses_declared <- function (path, end_date = NULL) {
1919
return (length (lic_dat) > 0L)
2020
}
2121

22+
cm_metric_licenses_declared_url <- function () {
23+
"chaoss.community/kb/metric-licenses-declared"
24+
}
25+
2226
#' Metric fo rnumber of files with declared licenses
2327
#'
2428
#' \url{https://chaoss.community/kb/metric-license-coverage/}
@@ -77,6 +81,10 @@ cm_metric_license_coverage <- function (path,
7781
cm_data_license_coverage (path, end_date, dirs)
7882
}
7983

84+
cm_metric_license_coverage_url <- function () {
85+
"chaoss.community/kb/metric-license-coverage"
86+
}
87+
8088
included_exts <- c ("r", "q", "qmd", "rmd", "c", "cpp", "h", "js", "py")
8189

8290
# https://www.r-project.org/Licenses/

R/cm-metric-maintainer-count.R

+4-2
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ cm_metric_maintainer_count <- function (path, end_date = Sys.Date ()) {
5252
return (dat [["recent"]])
5353
}
5454

55+
cm_metric_maintainer_count_url <- function () {
56+
"metric-contributors"
57+
}
58+
5559
#' Match repo contributors from both git log and GitHub API to author names and
5660
#' emails given in "DESCRIPTION" file.
5761
#'
@@ -95,8 +99,6 @@ match_repo_ctbs_to_desc <- function (path, desc_auts, gh_auts) {
9599
return (max (c (n_from_log, n_from_gh)))
96100
}
97101

98-
99-
100102
get_desc_authors <- function (path, roles = c ("cre", "aut")) {
101103

102104
desc_path <- fs::dir_ls (path, type = "file", regexp = "DESCRIPTION$")

R/cm-metric-num-ctb.R

+4
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,7 @@ cm_data_num_contributors <- function (path, end_date = Sys.Date ()) {
2727
cm_metric_num_contributors <- function (path, end_date = Sys.Date ()) {
2828
cm_data_num_contributors (path, end_date)
2929
}
30+
31+
cm_metric_num_contributors_url <- function () {
32+
"metric-contributors"
33+
}

R/cm-metric-popularity.R

+8
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,11 @@ cm_metric_num_stars <- function (path, end_date = Sys.Date ()) {
3636
dat <- cm_data_popularity (path, end_date)
3737
return (dat [["stars"]])
3838
}
39+
40+
cm_metric_num_forks_url <- function () {
41+
"metric-project-popularity"
42+
}
43+
44+
cm_metric_num_stars_url <- function () {
45+
"metric-project-popularity"
46+
}

R/cm-metric-release-freq.R

+8
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ cm_metric_release_freq <- function (path, end_date = Sys.Date ()) {
3131
return (dat [["mean"]])
3232
}
3333

34+
cm_metric_release_freq_url <- function () {
35+
"metric-release-frequency"
36+
}
37+
3438
cm_data_recent_releases <- function (path, end_date = Sys.Date ()) {
3539

3640
# Suppress no visible binding note:
@@ -48,3 +52,7 @@ cm_data_recent_releases <- function (path, end_date = Sys.Date ()) {
4852
cm_metric_recent_releases <- function (path, end_date = Sys.Date ()) {
4953
cm_data_recent_releases (path, end_date)
5054
}
55+
56+
cm_metric_recent_releases_url <- function () {
57+
"metric-release-frequency"
58+
}

R/cm-metric-response-time.R

+4
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,7 @@ cm_data_response_time <- function (path, end_date = Sys.Date ()) {
1717
cm_metric_response_time <- function (path, end_date = Sys.Date ()) {
1818
cm_data_response_time (path, end_date)
1919
}
20+
21+
cm_metric_response_time_url <- function () {
22+
"metric-time-to-first-response"
23+
}

R/cm-metric-test-coverage.R

+4
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,7 @@ cm_metric_test_coverage_internal <- function (path, end_date = Sys.Date ()) {
4242
cm_data_test_coverage (path, end_date) / 100
4343
}
4444
cm_metric_test_coverage <- memoise::memoise (cm_metric_test_coverage_internal)
45+
46+
cm_metric_test_coverage_url <- function () {
47+
"metric-test-coverage"
48+
}

0 commit comments

Comments
 (0)