Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pkgstats data for #204 #205

Merged
merged 7 commits into from
Aug 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: pkgcheck
Title: rOpenSci Package Checks
Version: 0.1.2.046
Version: 0.1.2.053
Authors@R: c(
person("Mark", "Padgham", , "[email protected]", role = c("aut", "cre"),
comment = c(ORCID = "0000-0003-2172-5265")),
Expand All @@ -26,6 +26,7 @@ Imports:
glue,
goodpractice,
httr,
httr2,
jsonlite,
magrittr,
methods,
Expand Down Expand Up @@ -55,4 +56,4 @@ Language: en-GB
LazyData: true
NeedsCompilation: yes
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.3.1
RoxygenNote: 7.3.2
4 changes: 0 additions & 4 deletions R/pkgcheck-package.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,3 @@
## usethis namespace: start
## usethis namespace: end
NULL

#' Statistics on all CRAN packages from 'pkgstats'
#' @family data
"pkgstats_data"
62 changes: 60 additions & 2 deletions R/stats-checks.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

#' Compare 'pkgstats' summary with statistics from all CRAN packages.
#' @param s Result of `pkgstats::pkgstats_summary`
#' @param threshold Proportion threshold below which to report on statistically
Expand All @@ -17,7 +16,7 @@
}


dat <- pkgcheck::pkgstats_data
dat <- get_pkgstats_data ()

# convert blank line measures into relative
b_s <- grep ("^blank\\_lines", names (s))
Expand Down Expand Up @@ -167,3 +166,62 @@

return (pc)
}

get_pkgstats_data <- function () {

cache_path <- Sys.getenv ("PKGCHECK_CACHE_DIR")
f_name <- "pkgstats-CRAN-current.Rds"
f_path <- fs::path_norm (fs::path (cache_path, f_name))

f_path <- dl_pkgstats_data (f_path)

readRDS (f_path)
}

dl_pkgstats_data <- function (f_path) {

# The cache_path is set to tempdir in tests, in which case static data must
# be used in order to generate reproducible test snapshots (see #204).
# Default is otherwise to use daily updates of data which then constnatly
# change snapshot results.
cache_path <- Sys.getenv ("PKGCHECK_CACHE_DIR")
cache_is_temp <- identical (
normalizePath (dirname (cache_path)),
normalizePath (tempdir ())
)

pkgstats_remote <- "https://github.com/ropensci-review-tools/pkgstats/"
u_tag <- ifelse (
cache_is_temp,
"v0.1.2",
utils::getFromNamespace ("RELEASE_TAG", "pkgstats")
)
u_base <- paste0 (pkgstats_remote, "releases/download/", u_tag, "/")
f_name <- "pkgstats-CRAN-current.Rds"
url <- paste0 (u_base, f_name)

latest <- FALSE
# Data are updated if older than:
update_days <- 7L
if (fs::file_exists (f_path)) {
latest <- difftime (
Sys.Date (),
as.Date (fs::file_info (f_path)$modification_time),
units = "days"
) <= update_days
}

if (!latest) {
req <- httr2::request (url) |>
httr2::req_headers ("Accept" = "application/octet-stream")
resp <- httr2::req_perform (req)

if (httr2::resp_is_error (resp)) {
return (NULL)

Check warning on line 220 in R/stats-checks.R

View check run for this annotation

Codecov / codecov/patch

R/stats-checks.R#L220

Added line #L220 was not covered by tests
}

writeBin (httr2::resp_body_raw (resp), f_path)
}

return (f_path)
}
68 changes: 37 additions & 31 deletions codemeta.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
"codeRepository": "https://github.com/ropensci-review-tools/pkgcheck",
"issueTracker": "https://github.com/ropensci-review-tools/pkgcheck/issues",
"license": "https://spdx.org/licenses/GPL-3.0",
"version": "0.1.2.046",
"version": "0.1.2.053",
"programmingLanguage": {
"@type": "ComputerLanguage",
"name": "R",
"url": "https://r-project.org"
},
"runtimePlatform": "R version 4.3.0 (2023-04-21)",
"runtimePlatform": "R version 4.4.1 (2024-06-14)",
"author": [
{
"@type": "Person",
Expand Down Expand Up @@ -118,26 +118,14 @@
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=visNetwork"
},
{
"@type": "SoftwareApplication",
"identifier": "withr",
"name": "withr",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=withr"
}
],
"softwareRequirements": {
"1": {
"@type": "SoftwareApplication",
"identifier": "R",
"name": "R",
"version": ">= 3.4.0"
"version": ">= 3.5.0"
},
"2": {
"@type": "SoftwareApplication",
Expand Down Expand Up @@ -233,7 +221,7 @@
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=goodpractice"
"sameAs": "https://github.com/mangothecat/goodpractice"
},
"10": {
"@type": "SoftwareApplication",
Expand All @@ -248,6 +236,18 @@
"sameAs": "https://CRAN.R-project.org/package=httr"
},
"11": {
"@type": "SoftwareApplication",
"identifier": "httr2",
"name": "httr2",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=httr2"
},
"12": {
"@type": "SoftwareApplication",
"identifier": "jsonlite",
"name": "jsonlite",
Expand All @@ -259,7 +259,7 @@
},
"sameAs": "https://CRAN.R-project.org/package=jsonlite"
},
"12": {
"13": {
"@type": "SoftwareApplication",
"identifier": "magrittr",
"name": "magrittr",
Expand All @@ -271,24 +271,18 @@
},
"sameAs": "https://CRAN.R-project.org/package=magrittr"
},
"13": {
"14": {
"@type": "SoftwareApplication",
"identifier": "methods",
"name": "methods"
},
"14": {
"15": {
"@type": "SoftwareApplication",
"identifier": "pkgstats",
"name": "pkgstats",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://github.com/ropensci-review-tools/pkgstats"
},
"15": {
"16": {
"@type": "SoftwareApplication",
"identifier": "rappdirs",
"name": "rappdirs",
Expand All @@ -300,7 +294,7 @@
},
"sameAs": "https://CRAN.R-project.org/package=rappdirs"
},
"16": {
"17": {
"@type": "SoftwareApplication",
"identifier": "rmarkdown",
"name": "rmarkdown",
Expand All @@ -312,7 +306,7 @@
},
"sameAs": "https://CRAN.R-project.org/package=rmarkdown"
},
"17": {
"18": {
"@type": "SoftwareApplication",
"identifier": "rprojroot",
"name": "rprojroot",
Expand All @@ -324,7 +318,7 @@
},
"sameAs": "https://CRAN.R-project.org/package=rprojroot"
},
"18": {
"19": {
"@type": "SoftwareApplication",
"identifier": "rvest",
"name": "rvest",
Expand All @@ -336,15 +330,27 @@
},
"sameAs": "https://CRAN.R-project.org/package=rvest"
},
"19": {
"20": {
"@type": "SoftwareApplication",
"identifier": "srr",
"name": "srr",
"sameAs": "https://github.com/ropensci-review-tools/srr"
},
"21": {
"@type": "SoftwareApplication",
"identifier": "withr",
"name": "withr",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=withr"
},
"SystemRequirements": {}
},
"fileSize": "3763.696KB",
"fileSize": "259.412KB",
"readme": "https://github.com/ropensci-review-tools/pkgcheck/blob/main/README.md",
"contIntegration": [
"https://github.com/ropensci-review-tools/pkgcheck/actions?query=workflow%3AR-CMD-check",
Expand Down
Binary file removed data/pkgstats_data.rda
Binary file not shown.
17 changes: 0 additions & 17 deletions man/pkgstats_data.Rd

This file was deleted.

Loading
Loading