Skip to content

Commit 88bf383

Browse files
authored
Merge pull request #97 from ropensci-review-tools/lang-fix
fix 🐛 in cm-metric-languages when no languages present
2 parents c6b7cb7 + d496282 commit 88bf383

File tree

4 files changed

+16
-13
lines changed

4 files changed

+16
-13
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.5.028
3+
Version: 0.1.5.030
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-languages.R

+2-2
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ cm_metric_languages <- function (path, end_date = NULL) {
3333
dplyr::group_by (s, language) |>
3434
dplyr::summarise (nfiles = sum (nfiles), ncode = sum (ncode)) |>
3535
dplyr::mutate (
36-
nfiles_pc = nfiles / sum (nfiles),
37-
ncode_pc = ncode / sum (ncode)
36+
nfiles_pc = ifelse (sum (nfiles) == 0, 0, nfiles / sum (nfiles)),
37+
ncode_pc = ifelse (sum (ncode) == 0, 0, ncode / sum (ncode))
3838
)
3939
}

R/cm-models.R

+12-9
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#' \url{https://chaoss.community/kb/metrics-model-development-responsiveness/}
44
#' \url{https://github.com/ropensci-review-tools/repometrics/issues/4}.
55
#'
6-
#' Values are in days, with lower better than higher.
6+
#' Higher values are better than lower values.
77
#'
88
#' This takes the four metrics of:
99
#' 1. Review cycle duration within a change request (in days)
@@ -13,9 +13,11 @@
1313
#' measured in both mean and median forms, and converts all measured values to
1414
#' aggregate mean and median values.
1515
#'
16-
#' @return A single numeric value of the mean of all of the four values. As
17-
#' this is in days, it is converted to log 10, with both NA values and values <
18-
#' 1 converted to values of 1 prior to log.
16+
#' @return A single numeric value formed from the mean of all of the four
17+
#' values. As this is in days, it is converted to log 10, with both NA values
18+
#' and values < 1 converted to values of 1 prior to log. The final value is
19+
#' then two minus this value, so higher values are better, and all are assessed
20+
#' against a standard scale of 100 days (log10(100) = 2).
1921
#'
2022
#' @noRd
2123
cm_model_dev_responsiveness <- function (path,
@@ -55,9 +57,10 @@ cm_model_dev_responsiveness <- function (path,
5557
vals [which (is.na (vals))] <- NA_real_
5658

5759
# But only return mean value, to align with all others
58-
val <- vals [["mean"]]
59-
val <- ifelse (is.na (val) | val < 1, 1, val)
60-
return (log10 (val))
60+
# And convert final value to scale so that higher is better by
61+
val <- 2 - log10 (vals [["mean"]])
62+
val <- ifelse (is.na (val), 0, val)
63+
return (val)
6164
}
6265

6366
#' CHAOSS model "project engagement"
@@ -232,7 +235,7 @@ cm_model_community_activity <- function (path,
232235
#' \url{https://chaoss.community/kb/metrics-model-oss-project-viability-compliance-security/}
233236
#' \url{https://github.com/ropensci-review-tools/repometrics/issues/8}
234237
#'
235-
#' Higher values are better than higher values.
238+
#' Higher values are better than lower values.
236239
#'
237240
#' @noRd
238241
cm_model_oss_compliance <- function (path,
@@ -474,7 +477,7 @@ cm_model_viability_strategy <- function (path,
474477

475478
lang_dist_mn <- mean (langs$ncode_pc) # lower is better
476479
# Re-scale this so that 4 languages translates to a value of 1:
477-
lang_dist_mn <- 0.25 / lang_dist_mn
480+
lang_dist_mn <- ifelse (lang_dist_mn == 0, 0, 0.25 / lang_dist_mn)
478481

479482
bus <- log10 (bus [["ncommits"]]) # higher is better
480483
ele <- log10 (ele [["ncommits"]]) # higher is better

codemeta.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"codeRepository": "https://github.com/ropensci-review-tools/repometrics",
99
"issueTracker": "https://github.com/ropensci-review-tools/repometrics/issues",
1010
"license": "https://spdx.org/licenses/GPL-3.0",
11-
"version": "0.1.5.028",
11+
"version": "0.1.5.030",
1212
"programmingLanguage": {
1313
"@type": "ComputerLanguage",
1414
"name": "R",

0 commit comments

Comments
 (0)