Skip to content

Commit 1b56981

Browse files
authored
Merge pull request #125 from ropensci-review-tools/models
change 'cm_metrics' defs to 'cm_data' for #124
2 parents 027e2c0 + 423e985 commit 1b56981

27 files changed

+218
-47
lines changed

DESCRIPTION

+1-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.082
3+
Version: 0.1.6.088
44
Authors@R:
55
person("Mark", "Padgham", , "mark.padgham@email.com", role = c("aut", "cre"),
66
comment = c(ORCID = "0000-0003-2172-5265"))

R/cm-metric-best-practices.R

+5-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#' provide a consistent interface).
1010
#'
1111
#' @noRd
12-
cm_metric_best_practices <- function (path, end_date = NULL) {
12+
cm_data_best_practices <- function (path, end_date = NULL) {
1313
readme_path <- fs::dir_ls (path, regexp = "readme\\.md", ignore.case = TRUE)
1414
if (length (readme_path) == 0L) {
1515
return (FALSE)
@@ -21,3 +21,7 @@ cm_metric_best_practices <- function (path, end_date = NULL) {
2121
ptn <- paste0 (c (ptn_ci, ptn_ossf), collapse = "|")
2222
return (any (grepl (ptn, readme)))
2323
}
24+
25+
cm_metric_best_practices <- function (path, end_date = NULL) {
26+
cm_data_best_practices (path, end_date)
27+
}

R/cm-metric-burstiness.R

+5-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#'
1010
#' \url{https://chaoss.community/kb/metric-burstiness/}.
1111
#' @noRd
12-
cm_metric_burstiness <- function (path, end_date, band_len = 31L, band_width = 2) {
12+
cm_data_burstiness <- function (path, end_date, band_len = 31L, band_width = 2) {
1313

1414
# Suppress no visible binding notes:
1515
timestamp <- ncommits <- mn <- sd <- upper <- lower <- outlier <- NULL
@@ -57,3 +57,7 @@ cm_metric_burstiness <- function (path, end_date, band_len = 31L, band_width = 2
5757

5858
return (ret)
5959
}
60+
61+
cm_metric_burstiness <- function (path, end_date, band_len = 31L, band_width = 2) {
62+
cm_data_burstiness (path, end_date, band_len = 31L, band_width = 2)
63+
}

R/cm-metric-change-req.R

+6-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
#' request.
2121
#' }
2222
#' @noRd
23-
cm_metric_change_req <- function (path, end_date = Sys.Date ()) {
23+
cm_data_change_req <- function (path, end_date = Sys.Date ()) {
2424

2525
log <- git_log_in_period (path, end_date)
2626
if (nrow (log) == 0) {
@@ -43,3 +43,8 @@ cm_metric_change_req <- function (path, end_date = Sys.Date ()) {
4343

4444
return (ret)
4545
}
46+
47+
cm_metric_change_req <- function (path, end_date = Sys.Date ()) {
48+
49+
cm_data_change_req (path, end_date)
50+
}

R/cm-metric-code-change.R

+10-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
cm_metric_code_change_lines <- function (path,
2-
end_date = Sys.Date (),
3-
exclude_whitespace = TRUE) {
1+
cm_data_code_change_lines <- function (path,
2+
end_date = Sys.Date (),
3+
exclude_whitespace = TRUE) {
44

55
log <- git_log_in_period (path, end_date)
66

@@ -12,3 +12,10 @@ cm_metric_code_change_lines <- function (path,
1212

1313
return (changes - ws)
1414
}
15+
16+
cm_metric_code_change_lines <- function (path,
17+
end_date = Sys.Date (),
18+
exclude_whitespace = TRUE) {
19+
20+
cm_data_code_change_lines (path, end_date, exclude_whitespace)
21+
}

R/cm-metric-cran-downloads.R

+5-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#' @param end_date The date up to which download counts are to be aggregated.
66
#' @return A single integer counting the number of downloads.
77
#' @noRd
8-
cm_metric_cran_downloads <- function (path, end_date = Sys.Date ()) {
8+
cm_data_cran_downloads <- function (path, end_date = Sys.Date ()) {
99

1010
checkmate::assert_directory_exists (path)
1111
checkmate::assert_date (end_date)
@@ -20,6 +20,10 @@ cm_metric_cran_downloads <- function (path, end_date = Sys.Date ()) {
2020
return (sum (cran_dl$downloads))
2121
}
2222

23+
cm_metric_cran_downloads <- function (path, end_date = Sys.Date ()) {
24+
cm_data_cran_downloads (path, end_date)
25+
}
26+
2327
#' Download the full daily log over `nyears`, and use memoised return value to
2428
#' filter to desired period for subsequent calls.
2529
#' @noRd

R/cm-metric-ctb-absence.R

+5-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#' @param path Local path to repository
1111
#' @param end_date Date at which metric is to be calculated.
1212
#' @noRd
13-
cm_metric_contrib_absence <- function (path, end_date = Sys.Date ()) {
13+
cm_data_contrib_absence <- function (path, end_date = Sys.Date ()) {
1414

1515
checkmate::assert_date (end_date)
1616

@@ -21,6 +21,10 @@ cm_metric_contrib_absence <- function (path, end_date = Sys.Date ()) {
2121
gitlog_absence_factor (log)
2222
}
2323

24+
cm_metric_contrib_absence <- function (path, end_date = Sys.Date ()) {
25+
cm_data_contrib_absence (path, end_date)
26+
}
27+
2428
gitlog_absence_factor <- function (log) {
2529

2630
# Count number of unique contributors needed to exceed 50%:

R/cm-metric-ctb-count.R

+10-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#' issue authors, and issue comments participants over a certain period of
66
#' time."
77
#' @noRd
8-
cm_metric_ctb_count <- function (path, end_date = Sys.Date ()) {
8+
cm_data_ctb_count <- function (path, end_date = Sys.Date ()) {
99

1010
# Suppress no visible binding note:
1111
created_at <- NULL
@@ -30,6 +30,10 @@ cm_metric_ctb_count <- function (path, end_date = Sys.Date ()) {
3030
)
3131
}
3232

33+
cm_metric_ctb_count <- function (path, end_date = Sys.Date ()) {
34+
cm_data_ctb_count (path, end_date)
35+
}
36+
3337
#' CHAOSS metric for committer count
3438
#'
3539
#' \url{https://chaoss.community/kb/metric-committers/}.
@@ -40,7 +44,7 @@ cm_metric_ctb_count <- function (path, end_date = Sys.Date ()) {
4044
#' D2_count: Contributors who have created a merge request and successfully
4145
#' merged code."
4246
#' @noRd
43-
cm_metric_committer_count <- function (path, end_date = Sys.Date ()) {
47+
cm_data_committer_count <- function (path, end_date = Sys.Date ()) {
4448

4549
# Suppress no visible binding note:
4650
starred_at <- created <- org_repo <- created_at <- NULL
@@ -72,3 +76,7 @@ cm_metric_committer_count <- function (path, end_date = Sys.Date ()) {
7276
prs = length (ctbs2)
7377
)
7478
}
79+
80+
cm_metric_committer_count <- function (path, end_date = Sys.Date ()) {
81+
cm_data_committer_count (path, end_date)
82+
}

R/cm-metric-ctb-types.R

+5-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#' \url{https://chaoss.community/kb/metric-types-of-contributions/}.
99
#'
1010
#' @noRd
11-
cm_metric_ctb_diversity <- function (path, end_date = Sys.Date ()) {
11+
cm_data_ctb_diversity <- function (path, end_date = Sys.Date ()) {
1212

1313
# Suppress no visible binding notes:
1414
updated_at <- NULL
@@ -39,3 +39,7 @@ cm_metric_ctb_diversity <- function (path, end_date = Sys.Date ()) {
3939

4040
return (length (setdiff (cmt_aut, main_auts)) / length (main_auts))
4141
}
42+
43+
cm_metric_ctb_diversity <- function (path, end_date = Sys.Date ()) {
44+
cm_data_ctb_diversity (path, end_date)
45+
}

R/cm-metric-elephant-factor.R

+5-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#' \url{https://chaoss.community/kb/metric-elephant-factor/}.
66
#'
77
#' @noRd
8-
cm_metric_elephant_factor <- function (path, end_date = Sys.Date ()) {
8+
cm_data_elephant_factor <- function (path, end_date = Sys.Date ()) {
99

1010
# Suppress no visible binding note:
1111
name <- company <- ncommits <- nfiles_changed <- lines_changed <- NULL
@@ -35,3 +35,7 @@ cm_metric_elephant_factor <- function (path, end_date = Sys.Date ()) {
3535

3636
gitlog_absence_factor (log)
3737
}
38+
39+
cm_metric_elephant_factor <- function (path, end_date = Sys.Date ()) {
40+
cm_data_elephant_factor (path, end_date)
41+
}

R/cm-metric-has-ci.R

+5-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ has_gh_ci_tests <- function (path) {
2828

2929
# 'end_date' not used here, but specified for consistent interface to all
3030
# metric fns.
31-
cm_metric_has_ci <- function (path, end_date = NULL) {
31+
cm_data_has_ci <- function (path, end_date = NULL) {
3232

3333
is_test_env <- Sys.getenv ("REPOMETRICS_TESTS") == "true"
3434
has_ci <- ifelse (is_test_env, FALSE, has_gh_ci_tests (path))
@@ -46,3 +46,7 @@ cm_metric_has_ci <- function (path, end_date = NULL) {
4646

4747
return (has_ci)
4848
}
49+
50+
cm_metric_has_ci <- function (path, end_date = NULL) {
51+
cm_data_has_ci (path, end_date)
52+
}

R/cm-metric-issue-updates.R

+15-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#' \url{https://chaoss.community/kb/metrics-model-community-activity/}
44
#' "The number of issues updated over a certain period of time."
55
#' @noRd
6-
cm_metric_issue_updates <- function (path, end_date = Sys.Date ()) {
6+
cm_data_issue_updates <- function (path, end_date = Sys.Date ()) {
77

88
# Suppress no visible binding note:
99
created_at <- NULL
@@ -21,7 +21,11 @@ cm_metric_issue_updates <- function (path, end_date = Sys.Date ()) {
2121
length (issue_nums)
2222
}
2323

24-
cm_metric_issue_cmt_count <- function (path, end_date = Sys.Date ()) {
24+
cm_metric_issue_updates <- function (path, end_date = Sys.Date ()) {
25+
cm_data_issue_updates (path, end_date)
26+
}
27+
28+
cm_data_issue_cmt_count <- function (path, end_date = Sys.Date ()) {
2529

2630
# Suppress no visible binding note:
2731
created_at <- issue_number <- NULL
@@ -48,7 +52,11 @@ cm_metric_issue_cmt_count <- function (path, end_date = Sys.Date ()) {
4852
return (mn_med_sum (cmts))
4953
}
5054

51-
cm_metric_issues_closed <- function (path, end_date = Sys.Date ()) {
55+
cm_metric_issue_cmt_count <- function (path, end_date = Sys.Date ()) {
56+
cm_data_issue_cmt_count (path, end_date)
57+
}
58+
59+
cm_data_issues_closed <- function (path, end_date = Sys.Date ()) {
5260

5361
# Suppress no visible binding note:
5462
closed_at <- NULL
@@ -62,3 +70,7 @@ cm_metric_issues_closed <- function (path, end_date = Sys.Date ()) {
6270

6371
nrow (issues)
6472
}
73+
74+
cm_metric_issues_closed <- function (path, end_date = Sys.Date ()) {
75+
cm_data_issues_closed (path, end_date)
76+
}

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

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
cm_metric_issues_to_prs <- function (path, end_date = Sys.Date ()) {
1+
cm_data_issues_to_prs <- function (path, end_date = Sys.Date ()) {
22

33
prs <- get_prs_in_period (path, end_date) # in cm-metrics-change-req.R
44
issues <- get_issues_in_period (path, end_date)
@@ -11,6 +11,10 @@ cm_metric_issues_to_prs <- function (path, end_date = Sys.Date ()) {
1111
return (ret)
1212
}
1313

14+
cm_metric_issues_to_prs <- function (path, end_date = Sys.Date ()) {
15+
cm_data_issues_to_prs (path, end_date)
16+
}
17+
1418
get_issues_in_period <- function (path,
1519
end_date = Sys.Date (),
1620
closed_only = FALSE) {

R/cm-metric-labels.R

+5-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
#' have been added at any time after an actual creation date of each issue.
2121
#'
2222
#' @noRd
23-
cm_metric_label_inclusivity <- function (path, end_date = Sys.Date ()) {
23+
cm_data_label_inclusivity <- function (path, end_date = Sys.Date ()) {
2424

2525
# suppress no visible binding notes:
2626
created_at <- NULL
@@ -53,3 +53,7 @@ cm_metric_label_inclusivity <- function (path, end_date = Sys.Date ()) {
5353
prop_friendly_overall = prop_friendly_overall
5454
)
5555
}
56+
57+
cm_metric_label_inclusivity <- function (path, end_date = Sys.Date ()) {
58+
cm_data_label_inclusivity (path, end_date)
59+
}

R/cm-metric-languages.R

+5-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#' @param end_date Not used here, but specified for consistent interface to all
77
#' metric fns.
88
#' @noRd
9-
cm_metric_languages <- function (path, end_date = NULL) {
9+
cm_data_languages <- function (path, end_date = NULL) {
1010

1111
# Suppress no visible binding note:
1212
language <- nfiles <- ncode <- NULL
@@ -37,3 +37,7 @@ cm_metric_languages <- function (path, end_date = NULL) {
3737
ncode_pc = ifelse (sum (ncode) == 0, 0, ncode / sum (ncode))
3838
)
3939
}
40+
41+
cm_metric_languages <- function (path, end_date = NULL) {
42+
cm_data_languages (path, end_date)
43+
}

R/cm-metric-licenses.R

+10-3
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ cm_metric_licenses_declared <- function (path, end_date = NULL) {
2222
#' @param dirs Directories to include in assessing files for license coverage.
2323
#' metric fns.
2424
#' @noRd
25-
cm_metric_license_coverage <- function (path,
26-
end_date = NULL,
27-
dirs = c ("R", "src", "inst/extdata")) {
25+
cm_data_license_coverage <- function (path,
26+
end_date = NULL,
27+
dirs = c ("R", "src", "inst/extdata")) {
2828

2929
requireNamespace ("readr", quietly = TRUE)
3030

@@ -64,6 +64,13 @@ cm_metric_license_coverage <- function (path,
6464
return (length (which (has_license)) / length (flist))
6565
}
6666

67+
cm_metric_license_coverage <- function (path,
68+
end_date = NULL,
69+
dirs = c ("R", "src", "inst/extdata")) {
70+
71+
cm_data_license_coverage (path, end_date, dirs)
72+
}
73+
6774
included_exts <- c ("r", "q", "qmd", "rmd", "c", "cpp", "h", "js", "py")
6875

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

R/cm-metric-maintainer-count.R

+5-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#' counting only those who were active either in commits, issues, or pull
44
#' requests over the standard time period.
55
#' @noRd
6-
cm_metric_maintainer_count <- function (path, end_date = Sys.Date ()) {
6+
cm_data_maintainer_count <- function (path, end_date = Sys.Date ()) {
77

88
# Suppress no visible binding note:
99
user_login <- merged_by <- participants <- created_at <-
@@ -47,6 +47,10 @@ cm_metric_maintainer_count <- function (path, end_date = Sys.Date ()) {
4747
c (total = nrow (auts), recent = num_gh_auts)
4848
}
4949

50+
cm_metric_maintainer_count <- function (path, end_date = Sys.Date ()) {
51+
cm_data_maintainer_count (path, end_date)
52+
}
53+
5054
#' Match repo contributors from both git log and GitHub API to author names and
5155
#' emails given in "DESCRIPTION" file.
5256
#'

R/cm-metric-num-ctb.R

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
cm_metric_num_contributors <- function (path, end_date = Sys.Date ()) {
1+
cm_data_num_contributors <- function (path, end_date = Sys.Date ()) {
22

33
log <- git_log_in_period (path, end_date)
44

@@ -23,3 +23,7 @@ cm_metric_num_contributors <- function (path, end_date = Sys.Date ()) {
2323

2424
return (length (index))
2525
}
26+
27+
cm_metric_num_contributors <- function (path, end_date = Sys.Date ()) {
28+
cm_data_num_contributors (path, end_date)
29+
}

R/cm-metric-num-forks.R

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
cm_metric_num_forks <- function (path, end_date = Sys.Date ()) {
1+
cm_data_num_forks <- function (path, end_date = Sys.Date ()) {
22

33
forks <- rm_data_repo_forks (path)
44

@@ -7,3 +7,7 @@ cm_metric_num_forks <- function (path, end_date = Sys.Date ()) {
77

88
return (c (num_in_period = length (index), num_total = nrow (forks)))
99
}
10+
11+
cm_metric_num_forks <- function (path, end_date = Sys.Date ()) {
12+
cm_data_num_forks (path, end_date)
13+
}

R/cm-metric-popularity.R

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
cm_metric_popularity <- function (path, end_date = Sys.Date ()) {
1+
cm_data_popularity <- function (path, end_date = Sys.Date ()) {
22

33
# suppress no visible binding notes:
44
timestamp <- aut_email <- aut_name <- created <- starred_at <- NULL
@@ -26,3 +26,7 @@ cm_metric_popularity <- function (path, end_date = Sys.Date ()) {
2626
stars = nrow (stars)
2727
)
2828
}
29+
30+
cm_metric_popularity <- function (path, end_date = Sys.Date ()) {
31+
cm_data_popularity (path, end_date)
32+
}

0 commit comments

Comments
 (0)