Skip to content

Commit 1126f11

Browse files
committed
fix pkgstats-data when no stats generated
1 parent e1c50ce commit 1126f11

File tree

3 files changed

+18
-11
lines changed

3 files changed

+18
-11
lines changed

DESCRIPTION

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: githist
22
Title: Code analyses traced along the 'git' history of a package
3-
Version: 0.1.0.026
3+
Version: 0.1.0.027
44
Authors@R:
55
person("Mark", "Padgham", , "mark.padgham@email.com", role = c("aut", "cre"),
66
comment = c(ORCID = "0000-0003-2172-5265"))

R/pkgstats-data.R

+16-9
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,27 @@ run_one_pkgstats <- function (path, pkg_date) {
77
!grepl ("^anonFunc", s$objects$fn_name) &
88
!is.na (s$objects$npars)
99
)
10-
fns <- s$objects [index, ] |>
11-
dplyr::select ("fn_name", "language", "loc", "npars", "has_dots", "exported", "num_doclines")
10+
# Empty results do not contain all columns:
11+
nms <- c ("fn_name", "language", "loc", "npars", "has_dots", "exported", "num_doclines")
12+
nms <- nms [which (nms %in% names (s$objects))]
13+
fns <- s$objects [index, ] |> dplyr::select (dplyr::all_of (nms))
1214
doclines <- mn_med_sum (fns$num_doclines [which (!is.na (fns$num_doclines))])
1315
npars <- mn_med_sum (fns$npars)
1416
loc <- mn_med_sum (fns$loc)
1517

16-
fn_nms <- unique (fns [, c ("fn_name", "exported")])
18+
fn_nms <- data.frame (exported = logical (0L))
19+
if (nrow (fns) > 0L) {
20+
fn_nms <- unique (fns [, c ("fn_name", "exported")])
21+
}
1722

18-
package <- NULL # Suppress 'no visible binding' note.
19-
ext_calls <- s$external_calls |>
20-
dplyr::select ("call", "package") |>
21-
dplyr::group_by (package) |>
22-
dplyr::count (package) |>
23-
dplyr::filter (package != s$desc$package)
23+
package <- ext_calls <- NULL # Suppress 'no visible binding' note.
24+
if (!is.null (s$external_calls)) {
25+
ext_calls <- s$external_calls |>
26+
dplyr::select ("call", "package") |>
27+
dplyr::group_by (package) |>
28+
dplyr::count (package) |>
29+
dplyr::filter (package != s$desc$package)
30+
}
2431

2532
base_calls <- null2na_int (ext_calls$n [ext_calls$package == "base"])
2633
n_ext_pkgs <- null2na_int (nrow (ext_calls)) - 1L

codemeta.json

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

0 commit comments

Comments
 (0)