[](https://github.com/pharmaR/val.meter)
[](https://github.com/pharmaR/riskmetric/actions?workflow=R-CMD-check)
[](https://app.codecov.io/gh/pharmaR/riskmetric?branch=master)
`riskmetric` is a collection of risk metrics to evaluate the quality of R
packages.
> [!IMPORTANT]
>
> Lifecycle: **Maintenance Only**
>
> The _R Validation Hub_ is shifting development efforts to our new flagship
> assessment tool, [`{val.meter}`](https://github.com/pharmaR/val.meter). While
> development is not ending for `{riskmetric}`, it has shifted to
> maintenance-only. Please continue to file bug reports for erroneous behaviors,
> but for feature requests and discussion on approach, please head over to
> `{val.meter}`.
>
## Background
The risk of using an R package is evaluated based on a number of metrics meant
to evaluate development best practices, code documentation, community engagement
and development sustainability. We hope to provide a framework to quantify risk
by assessing these metrics. This package serves as a starting point for
exploring the heterogeneity of code quality, and begin a broader conversation
about the validation of R packages. Primarily, this effort aims to provide some
context for validation within regulated industries.
We separate three steps in the workflow to assess the risk of an R package using `riskmetric`:
1. **Finding a source for package information (installed package or CRAN/git source)** `pkg_ref()`
1. **Assessing the package under validation criteria** `pkg_assess()`
1. **Scoring assessment criteria** `pkg_score()`
The results will be assembled in a dataset of validation criteria containing an
overall risk score for each package as shown in the example below.
## Installation
You can install `riskmetric` from CRAN with:
```r
install.packages("riskmetric")
```
Or from GitHub using `devtools` with:
```r
devtools::install_github("pharmaR/riskmetric")
```
## Example
Scrape metadata locally or remotely, then assess that metadata and score it to
estimate risk. For each package, derive a composite measure of risk, or a
collection of individual scores which can be easily used to generate validation
reports.
```r
library(dplyr)
library(riskmetric)
pkg_ref(c("riskmetric", "utils", "tools")) %>%
pkg_assess() %>%
pkg_score()
```
## The `{riskassessment}` application
`riskassessment` is a full-fledged R package containing a shiny front-end that
augments the utility of `riskmetric`. The application's goal is to provide a
central hub for an organization to review and assess the risk of R packages,
providing handy tools and guide rails along the way. The app uses a local
database to store & display:
* all `riskmetric` metrics, including package risk scores over time
* organization-wide metric weighting, plus rules to automate org decisions
(whether to endorse/ prohibit the pkg)
* package-level user dialogue on the perceived risk, to facilitate communication
& notes
To learn more about `riskassessment`, please browse the [user guide](https://pharmar.github.io/riskassessment/) or consider
taking the [demo app](https://rinpharma.shinyapps.io/risk_assessment) for a spin.
## Get Involved
We have a bi-weekly sprint meeting for developers to discuss the progress.
* Contact `eric.milliman@biogen.com` to be added to the meeting.
* [Project Planning Meeting Structure](https://github.com/pharmaR/riskmetric/issues/57)
* [Milestone](https://github.com/pharmaR/riskmetric/milestones)
`riskmetric` is centrally a community project. Comfort with a quantification of
risk comes via consensus, and for that this project is dependent on close
community engagement. There are plenty of ways to help:
- Share the package
- File [issues](https://github.com/pharmaR/riskmetric/issues) when you encounter bugs
- Weigh in on proposed metrics, or [suggest a new one](https://github.com/pharmaR/riskmetric/issues/new?labels=Metric%20Proposal)
- Help us devise the best way to summarize risk into a single score
- Help us keep documentation up to date
- Contribute code to tackle the metric backlog
================================================
FILE: _pkgdown.yml
================================================
template:
bootstrap: 5
reference:
- title: "Package Reference"
desc: "Create Package Reference for Each Package Risk Metric and Cache Metadata"
contents:
- starts_with("pkg_ref")
- title: "Package Assessment"
desc: "Assess Package Metadata against a risk criterion"
contents:
- starts_with("pkg_assess")
- all_assessments
- get_assessments
- starts_with("assess")
- title: "Package Risk Score"
desc: "Provide Risk Score based on Risk Metrics"
contents:
- pkg_score
- starts_with("pkg_metric")
- starts_with("metric_score")
- title: "Package Risk Summary"
desc: "Summarizing across metric scores"
contents:
- summarize_scores
- title: "Metric Error Handler"
desc: "Error handler functions"
contents:
- starts_with("assessment_error")
- starts_with("score_error")
- title: "Utilities"
desc: "Utility functions"
contents:
- as_pkg_metric
- as_pkg_ref
================================================
FILE: cran-comments.md
================================================
## riskmetric 0.2.5
Resolved issues with CRAN checks.
Tested on Ubuntu Jammy, GitHub Action, and RHub.
## R CMD check results
0 errors | 0 warnings | 0 notes
================================================
FILE: man/all_assessments.Rd
================================================
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/pkg_assess.R
\name{all_assessments}
\alias{all_assessments}
\title{A default list of assessments to perform for each package}
\usage{
all_assessments()
}
\value{
a list of assess_* functions exported from riskmetric
}
\description{
A default list of assessments to perform for each package
}
================================================
FILE: man/allow_mutation.Rd
================================================
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/pkg_ref_class_extract.R
\name{allow_mutation}
\alias{allow_mutation}
\title{a wrapper to assert that a pkg_ref has been permitted to do an additional
mutation, used to handle recursive initialization of cached fields}
\usage{
allow_mutation(x, expr, envir = parent.frame())
}
\arguments{
\item{x}{a \code{pkg_ref} object}
\item{expr}{an expression to evaluate, and possible do a mutation within}
\item{envir}{an environment in which the expression is to be evaluated}
}
\value{
the result of \code{expr}
}
\description{
a wrapper to assert that a pkg_ref has been permitted to do an additional
mutation, used to handle recursive initialization of cached fields
}
\keyword{internal}
================================================
FILE: man/as_pkg_metric.Rd
================================================
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/pkg_metric.R
\name{as_pkg_metric}
\alias{as_pkg_metric}
\title{Convert an object to a \code{pkg_metric}}
\usage{
as_pkg_metric(x, class = c())
}
\arguments{
\item{x}{data to store as a \code{pkg_metric}}
\item{class}{a subclass to differentiate the \code{pkg_metric} object}
}
\value{
a \code{pkg_metric} object
}
\description{
Convert an object to a \code{pkg_metric}
}
================================================
FILE: man/as_pkg_metric_condition.Rd
================================================
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/pkg_metric_condition.R
\name{as_pkg_metric_condition}
\alias{as_pkg_metric_condition}
\title{A pkg_metric subclass for general metric evaluation conditions}
\usage{
as_pkg_metric_condition(x, ..., subclass = c())
}
\arguments{
\item{x}{an object to wrap in a \code{pkg_metric_condition} class}
\item{...}{additional arguments added as attributes to object \code{x}}
\item{subclass}{an optional subclass of \code{pkg_metric_condition} to
include}
}
\value{
an object after wrap \code{pkg_metric_condition} class.
}
\description{
A pkg_metric subclass for general metric evaluation conditions
}
\keyword{internal}
================================================
FILE: man/as_pkg_metric_error.Rd
================================================
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/pkg_metric_error.R
\name{as_pkg_metric_error}
\alias{as_pkg_metric_error}
\title{A subclass wrapping an error with an additional parent class}
\usage{
as_pkg_metric_error(error)
}
\arguments{
\item{error}{an error condition object to capture}
}
\value{
an error condition object after wrap \code{pkg_metric_error} class.
}
\description{
A subclass wrapping an error with an additional parent class
}
\keyword{internal}
================================================
FILE: man/as_pkg_metric_na.Rd
================================================
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/pkg_metric_na.R
\name{as_pkg_metric_na}
\alias{as_pkg_metric_na}
\title{A pkg_metric subclass for when metrics are explicitly not applicable}
\usage{
as_pkg_metric_na(x, message = NULL)
}
\arguments{
\item{x}{a \code{pkg_metric} object to wrap in a \code{pkg_metric_na}
subclass}
\item{message}{an optional message explaining why a metric is not applicable.}
}
\value{
a \code{pkg_metric} object after wrap in a \code{pkg_metric_na}
}
\description{
A pkg_metric subclass for when metrics are explicitly not applicable
}
\keyword{internal}
================================================
FILE: man/as_pkg_metric_todo.Rd
================================================
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/pkg_metric_todo.R
\name{as_pkg_metric_todo}
\alias{as_pkg_metric_todo}
\title{A pkg_metric subclass for when pkg_metrics have not yet been implemented}
\usage{
as_pkg_metric_todo(x, message = NULL)
}
\arguments{
\item{x}{a \code{pkg_metric} object to wrap in a \code{pkg_metric_todo}
subclass}
\item{message}{an optional message directing users and potential contributors
toward any ongoing work or first steps toward development.}
}
\value{
a \code{pkg_metric} object after wrap in a \code{pkg_metric_todo}
}
\description{
A pkg_metric subclass for when pkg_metrics have not yet been implemented
}
\keyword{internal}
================================================
FILE: man/assess_covr_coverage.Rd
================================================
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/assess_covr_coverage.R
\name{assess_covr_coverage}
\alias{assess_covr_coverage}
\title{Assess a package code coverage using the `covr` package}
\usage{
assess_covr_coverage(x, ...)
}
\arguments{
\item{x}{a \code{pkg_ref} package reference object}
\item{...}{additional arguments passed on to S3 methods, rarely used}
}
\value{
a \code{pkg_metric} containing a list containing fields 'filecoverage' and 'totalcoverage' containing a named numeric vector of file unit test coverage and a singular numeric value representing overall test coverage respectively.
}
\description{
Assess a package code coverage using the `covr` package
}
\examples{
\dontrun{
assess_covr_coverage(pkg_ref("riskmetric"))
}
}
\seealso{
\code{\link{metric_score.pkg_metric_covr_coverage}}
}
================================================
FILE: man/assess_dependencies.Rd
================================================
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/assess_dependencies.R
\name{assess_dependencies}
\alias{assess_dependencies}
\title{Assessment of dependency footprint for a specific package}
\usage{
assess_dependencies(x, ...)
}
\arguments{
\item{x}{a \code{pkg_ref} package reference object}
\item{...}{additional arguments passed on to S3 methods, rarely used}
}
\value{
a \code{pkg_metric} containing a dataframe of package names and they type of dependency the package being assess has to them
}
\description{
Only Depends, Imports and LinkingTo dependencies are assessed because
they are required
}
\details{
The more packages a package relies on the more chances for errors exist.
}
\examples{
\dontrun{
assess_dependencies(pkg_ref("riskmetric"))
}
}
\seealso{
\code{\link{metric_score.pkg_metric_dependencies}}
}
================================================
FILE: man/assess_downloads_1yr.Rd
================================================
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/assess_downloads.R
\name{assess_downloads_1yr}
\alias{assess_downloads_1yr}
\title{Assess a package for the number of downloads in the past year}
\usage{
assess_downloads_1yr(x, ...)
}
\arguments{
\item{x}{a \code{pkg_ref} package reference object}
\item{...}{additional arguments passed on to S3 methods, rarely used}
}
\value{
a \code{pkg_metric} containing a numeric value between [0,1] indicating the volume of downloads
}
\description{
Assess a package for the number of downloads in the past year
}
\details{
The more times a package has been downloaded the more extensive the user testing and the greater chance there is of someone finding a bug and logging it.
}
\examples{
\dontrun{
assess_downloads_1yr(pkg_ref("riskmetric"))
}
}
\seealso{
\code{\link{metric_score.pkg_metric_downloads_1yr}}
}
================================================
FILE: man/assess_export_help.Rd
================================================
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/assess_export_help.R
\name{assess_export_help}
\alias{assess_export_help}
\title{Assess a package for availability of documentation for exported values}
\usage{
assess_export_help(x, ...)
}
\arguments{
\item{x}{a \code{pkg_ref} package reference object}
\item{...}{additional arguments passed on to S3 methods, rarely used}
}
\value{
a \code{pkg_metric} containing a logical vector indicating existence of documentation for each namespace export
}
\description{
Assess a package for availability of documentation for exported values
}
\examples{
\dontrun{
assess_export_help(pkg_ref("riskmetric"))
}
}
\seealso{
\code{\link{metric_score.pkg_metric_export_help}}
}
================================================
FILE: man/assess_exported_namespace.Rd
================================================
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/assess_exported_namespace.R
\name{assess_exported_namespace}
\alias{assess_exported_namespace}
\title{Assess a package's results from running R CMD check}
\usage{
assess_exported_namespace(x, ...)
}
\arguments{
\item{x}{a \code{pkg_ref} package reference object}
\item{...}{additional arguments passed on to S3 methods, rarely used}
}
\value{
a \code{pkg_metric} containing List of functions and objects exported by a package, excluding S3methods
}
\description{
Assess a package's results from running R CMD check
}
\examples{
\dontrun{
assess_exported_namespace(pkg_ref("riskmetric"))
}
}
\seealso{
\code{\link{metric_score.pkg_metric_exported_namespace}}
}
================================================
FILE: man/assess_has_bug_reports_url.Rd
================================================
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/assess_has_bug_reports_url.R
\name{assess_has_bug_reports_url}
\alias{assess_has_bug_reports_url}
\title{Assess a package for the presence of a url field where bugs can be reported.}
\usage{
assess_has_bug_reports_url(x, ...)
}
\arguments{
\item{x}{a \code{pkg_ref} package reference object}
\item{...}{additional arguments passed on to S3 methods, rarely used}
}
\value{
a \code{pkg_metric} containing a character value containing the BugReports field contents
}
\description{
Assess a package for the presence of a url field where bugs can be reported.
}
\examples{
\dontrun{
assess_has_bug_reports_url(pkg_ref("riskmetric"))
}
}
\seealso{
\code{\link{metric_score.pkg_metric_has_bug_reports_url}}
}
================================================
FILE: man/assess_has_examples.Rd
================================================
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/assess_has_examples.R
\name{assess_has_examples}
\alias{assess_has_examples}
\title{Assess a package for the presence of example or usage fields in function documentation}
\usage{
assess_has_examples(x, ...)
}
\arguments{
\item{x}{a \code{pkg_ref} package reference object}
\item{...}{additional arguments passed on to S3 methods, rarely used}
}
\value{
a \code{pkg_metric} containing an integer value indicating the proportion of discovered files with examples
}
\description{
Assess a package for the presence of example or usage fields in function documentation
}
\examples{
\dontrun{
assess_has_examples(pkg_ref("riskmetric"))
}
}
\seealso{
\code{\link{metric_score.pkg_metric_has_examples}}
}
================================================
FILE: man/assess_has_maintainer.Rd
================================================
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/assess_has_maintainer.R
\name{assess_has_maintainer}
\alias{assess_has_maintainer}
\title{Assess a package for an associated maintainer}
\usage{
assess_has_maintainer(x, ...)
}
\arguments{
\item{x}{a \code{pkg_ref} package reference object}
\item{...}{additional arguments passed on to S3 methods, rarely used}
}
\value{
a \code{pkg_metric} containing a character vector of maintainers associated with the package
}
\description{
Assess a package for an associated maintainer
}
\examples{
\dontrun{
assess_has_maintainer(pkg_ref("riskmetric"))
}
}
\seealso{
\code{\link{metric_score.pkg_metric_has_maintainer}}
}
================================================
FILE: man/assess_has_news.Rd
================================================
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/assess_has_news.R
\name{assess_has_news}
\alias{assess_has_news}
\title{Assess a package for the presence of a NEWS file}
\usage{
assess_has_news(x, ...)
}
\arguments{
\item{x}{a \code{pkg_ref} package reference object}
\item{...}{additional arguments passed on to S3 methods, rarely used}
}
\value{
a \code{pkg_metric} containing an integer value indicating the number of discovered NEWS files
}
\description{
Assess a package for the presence of a NEWS file
}
\examples{
\dontrun{
assess_has_news(pkg_ref("riskmetric"))
}
}
\seealso{
\code{\link{metric_score.pkg_metric_has_news}}
}
================================================
FILE: man/assess_has_source_control.Rd
================================================
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/assess_has_source_control.R
\name{assess_has_source_control}
\alias{assess_has_source_control}
\title{Assess a package for an associated source control url}
\usage{
assess_has_source_control(x, ...)
}
\arguments{
\item{x}{a \code{pkg_ref} package reference object}
\item{...}{additional arguments passed on to S3 methods, rarely used}
}
\value{
a \code{pkg_metric} containing a character vector of source control urls associated with the package
}
\description{
Assess a package for an associated source control url
}
\examples{
\dontrun{
assess_has_source_control(pkg_ref("riskmetric"))
}
}
\seealso{
\code{\link{metric_score.pkg_metric_has_source_control}}
}
================================================
FILE: man/assess_has_vignettes.Rd
================================================
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/assess_has_vignettes.R
\name{assess_has_vignettes}
\alias{assess_has_vignettes}
\title{Assess a package for the presence of Vignettes files}
\usage{
assess_has_vignettes(x, ...)
}
\arguments{
\item{x}{a \code{pkg_ref} package reference object}
\item{...}{additional arguments passed on to S3 methods, rarely used}
}
\value{
a \code{pkg_metric} containing an integer value indicating the number of discovered vignettes files
}
\description{
Assess a package for the presence of Vignettes files
}
\examples{
\dontrun{
assess_has_vignettes(pkg_ref("riskmetric"))
}
}
\seealso{
\code{\link{metric_score.pkg_metric_has_vignettes}}
}
================================================
FILE: man/assess_has_website.Rd
================================================
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/assess_has_website.R
\name{assess_has_website}
\alias{assess_has_website}
\title{Assess a package for an associated website url}
\usage{
assess_has_website(x, ...)
}
\arguments{
\item{x}{a \code{pkg_ref} package reference object}
\item{...}{additional arguments passed on to S3 methods, rarely used}
}
\value{
a \code{pkg_metric} containing a character vector of website urls associated with the package
}
\description{
Assess a package for an associated website url
}
\examples{
\dontrun{
assess_has_website(pkg_ref("riskmetric"))
}
}
\seealso{
\code{\link{metric_score.pkg_metric_has_website}}
}
================================================
FILE: man/assess_last_30_bugs_status.Rd
================================================
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/assess_last_30_bugs_status.R
\name{assess_last_30_bugs_status}
\alias{assess_last_30_bugs_status}
\title{Assess how many recent BugReports have been closed}
\usage{
assess_last_30_bugs_status(x, ...)
}
\arguments{
\item{x}{a \code{pkg_ref} package reference object}
\item{...}{additional arguments passed on to S3 methods, rarely used}
}
\value{
a \code{pkg_metric} containing a logical vector indicating whether a recent BugReport was closed
}
\description{
Assess how many recent BugReports have been closed
}
\examples{
\dontrun{
assess_last_30_bugs_status(pkg_ref("riskmetric"))
}
}
\seealso{
\code{\link{metric_score.pkg_metric_last_30_bugs_status}}
}
================================================
FILE: man/assess_license.Rd
================================================
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/assess_license.R
\name{assess_license}
\alias{assess_license}
\title{Assess a package for an acceptable license}
\usage{
assess_license(x, ...)
}
\arguments{
\item{x}{a \code{pkg_ref} package reference object}
\item{...}{additional arguments passed on to S3 methods, rarely used}
}
\value{
a \code{pkg_metric} containing a string indicating the license under which the package is released
}
\description{
Assess a package for an acceptable license
}
\examples{
\dontrun{
assess_license(pkg_ref("riskmetric"))
}
}
\seealso{
\code{\link{metric_score.pkg_metric_license}}
}
================================================
FILE: man/assess_news_current.Rd
================================================
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/assess_news_current.R
\name{assess_news_current}
\alias{assess_news_current}
\title{Assess a package for an up-to-date NEWS file}
\usage{
assess_news_current(x, ...)
}
\arguments{
\item{x}{a \code{pkg_ref} package reference object}
\item{...}{additional arguments passed on to S3 methods, rarely used}
}
\value{
a \code{pkg_metric} containing a logical vector indicating whether each discovered NEWS file is up-to-date
}
\description{
Assess a package for an up-to-date NEWS file
}
\examples{
\dontrun{
assess_news_current(pkg_ref("riskmetric"))
}
}
\seealso{
\code{\link{metric_score.pkg_metric_news_current}}
}
================================================
FILE: man/assess_r_cmd_check.Rd
================================================
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/assess_r_cmd_check.R
\name{assess_r_cmd_check}
\alias{assess_r_cmd_check}
\title{Assess a package's results from running R CMD check}
\usage{
assess_r_cmd_check(x, ...)
}
\arguments{
\item{x}{a \code{pkg_ref} package reference object}
\item{...}{additional arguments passed on to S3 methods, rarely used}
}
\value{
a \code{pkg_metric} containing Tally of errors, warnings and notes from running R CMD check locally
}
\description{
Assess a package's results from running R CMD check
}
\examples{
\dontrun{
assess_r_cmd_check(pkg_ref("riskmetric"))
}
}
\seealso{
\code{\link{metric_score.pkg_metric_r_cmd_check}}
}
================================================
FILE: man/assess_remote_checks.Rd
================================================
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/assess_remote_checks.R
\name{assess_remote_checks}
\alias{assess_remote_checks}
\title{Assess package checks from CRAN/Bioc or R CMD check}
\usage{
assess_remote_checks(x, ...)
}
\arguments{
\item{x}{a \code{pkg_ref} package reference object}
\item{...}{additional arguments passed on to S3 methods, rarely used}
}
\value{
a \code{pkg_metric} containing Tally of R CMD check results run on differnt OS flavors by BioC or CRAN
}
\description{
Assess package checks from CRAN/Bioc or R CMD check
}
\examples{
\dontrun{
assess_remote_checks(pkg_ref("riskmetric"))
}
}
\seealso{
\code{\link{metric_score.pkg_metric_remote_checks}}
}
================================================
FILE: man/assess_reverse_dependencies.Rd
================================================
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/assess_reverse_dependencies.R
\name{assess_reverse_dependencies}
\alias{assess_reverse_dependencies}
\title{Generate list of Reverse Dependencies for a package}
\usage{
assess_reverse_dependencies(x, ...)
}
\arguments{
\item{x}{a \code{pkg_ref} package reference object}
\item{...}{additional arguments passed on to S3 methods, rarely used}
}
\value{
a \code{pkg_metric} containing A character vector of reverse dependencies
}
\description{
Generate list of Reverse Dependencies for a package
}
\details{
The more packages that depend on a package the more chance
for errors/bugs to be found
}
\examples{
\dontrun{
assess_reverse_dependencies(pkg_ref("riskmetric"))
}
}
\seealso{
\code{\link{metric_score.pkg_metric_reverse_dependencies}}
}
================================================
FILE: man/assess_size_codebase.Rd
================================================
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/assess_size_codebase.R
\name{assess_size_codebase}
\alias{assess_size_codebase}
\title{Assess a package for size of code base}
\usage{
assess_size_codebase(x, ...)
}
\arguments{
\item{x}{a \code{pkg_ref} package reference object}
\item{...}{additional arguments passed on to S3 methods, rarely used}
}
\value{
a \code{pkg_metric} containing a numeric value for number of lines of code base for a package
}
\description{
Assess a package for size of code base
}
\examples{
\dontrun{
assess_size_codebase(pkg_ref("riskmetric"))
}
}
\seealso{
\code{\link{metric_score.pkg_metric_size_codebase}}
}
================================================
FILE: man/assessment_error_as_warning.Rd
================================================
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/pkg_metric_error.R
\name{assessment_error_as_warning}
\alias{assessment_error_as_warning}
\title{Error handler for assessments to deescalate errors to warnings}
\usage{
assessment_error_as_warning(e, name, assessment)
}
\arguments{
\item{e}{an error raised during a package reference assessment}
\item{name}{the name of the package whose package reference assessment raised
the error}
\item{assessment}{the name of the assessment function which raised the error}
}
\value{
a pkg_metric object of pkg_metric_error subclass
}
\description{
Error handler for assessments to deescalate errors to warnings
}
\seealso{
Other assessment error handlers:
\code{\link{assessment_error_empty}()},
\code{\link{assessment_error_throw}()}
}
\concept{assessment error handlers}
================================================
FILE: man/assessment_error_empty.Rd
================================================
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/pkg_metric_error.R
\name{assessment_error_empty}
\alias{assessment_error_empty}
\title{Error handler for assessments with safe fallback}
\usage{
assessment_error_empty(e, ...)
}
\arguments{
\item{e}{an error raised during a package reference assessment}
\item{...}{additional arguments unused}
}
\value{
a pkg_metric object of pkg_metric_error subclass
}
\description{
Error handler for assessments with safe fallback
}
\seealso{
Other assessment error handlers:
\code{\link{assessment_error_as_warning}()},
\code{\link{assessment_error_throw}()}
}
\concept{assessment error handlers}
================================================
FILE: man/assessment_error_throw.Rd
================================================
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/pkg_metric_error.R
\name{assessment_error_throw}
\alias{assessment_error_throw}
\title{Error handler for assessments to throw error immediately}
\usage{
assessment_error_throw(e, name, assessment)
}
\arguments{
\item{e}{an error raised during a package reference assessment}
\item{name}{the name of the package whose package reference assessment raised
the error}
\item{assessment}{the name of the assessment function which raised the error}
}
\value{
the error encountered during assessment
}
\description{
Error handler for assessments to throw error immediately
}
\seealso{
Other assessment error handlers:
\code{\link{assessment_error_as_warning}()},
\code{\link{assessment_error_empty}()}
}
\concept{assessment error handlers}
================================================
FILE: man/available_pkg_ref_fields.Rd
================================================
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/pkg_ref_cache.R
\name{available_pkg_ref_fields}
\alias{available_pkg_ref_fields}
\title{A helper function for retrieving a list of available fields, identified based
on implementation of a pkg_ref_cache method for a given class.}
\usage{
available_pkg_ref_fields(x)
}
\arguments{
\item{x}{a package reference object}
}
\value{
a list of available fields implemented with a pkg_ref_cache method
}
\description{
A helper function for retrieving a list of available fields, identified based
on implementation of a pkg_ref_cache method for a given class.
}
\keyword{internal}
================================================
FILE: man/bare_env.Rd
================================================
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/pkg_ref_class_extract.R
\name{bare_env}
\alias{bare_env}
\title{evaluate an expression with a pkg_ref object reclassed as a bare environment
object, used to sidestep pkg_ref assignment guardrails}
\usage{
bare_env(x, expr, envir = parent.frame())
}
\arguments{
\item{x}{a \code{pkg_ref} object}
\item{expr}{an expression to evaluate, avoiding \code{pkg_ref} extraction
handlers}
\item{envir}{an environment in which the expression is to be evaluated}
}
\value{
the result of \code{expr}
}
\description{
evaluate an expression with a pkg_ref object reclassed as a bare environment
object, used to sidestep pkg_ref assignment guardrails
}
\keyword{internal}
================================================
FILE: man/bug_report_metadata.Rd
================================================
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/pkg_ref_cache_bug_reports.R
\name{bug_report_metadata}
\alias{bug_report_metadata}
\title{Helper for structuring bug reports}
\usage{
bug_report_metadata(bug_reports_data, x)
}
\arguments{
\item{bug_reports_data}{data to represent a bug report history - generally a
return object from making a request to a repository's issues API}
\item{x}{a \code{pkg_ref} object where a \code{bug_reports_host} field can be
found}
}
\value{
a \code{bug_reports_host} field
}
\description{
Helper for structuring bug reports
}
\keyword{internal}
================================================
FILE: man/cache_behaviors.Rd
================================================
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/pkg_ref_cache_behaviors.R
\docType{data}
\name{cache_behaviors}
\alias{cache_behaviors}
\title{List of available caching behaviors with metadata, including default and
annotations for building documentation}
\format{
An object of class \code{list} of length 1.
}
\usage{
cache_behaviors
}
\value{
a list contain cache behaviros information
}
\description{
List of available caching behaviors with metadata, including default and
annotations for building documentation
}
\keyword{internal}
================================================
FILE: man/capture_expr_output.Rd
================================================
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/utils.R
\name{capture_expr_output}
\alias{capture_expr_output}
\title{Capture side effects issued by an evaluated expression}
\usage{
capture_expr_output(expr, split = FALSE, env = parent.frame(), quoted = FALSE)
}
\arguments{
\item{expr}{an expression to evaluate, capturing output events as they
are issued}
\item{split}{logical: if \code{TRUE}, output will be sent to the new
sink and to the current output stream, like the Unix program \code{tee}.}
\item{env}{the environment in which \code{expr} should be evaluated,
defaulting to the calling environment.}
\item{quoted}{whether \code{expr} is a quoted object and should be evaluated
as is, or whether the expression should be captured from the function call.
Defaults to \code{FALSE}, capturing the passed expression.}
}
\value{
an with_eval_recording object
}
\description{
All messaging condition side effects are captured in the order that they
are issued.
}
\keyword{internal}
================================================
FILE: man/dec_mutations_count.Rd
================================================
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/pkg_ref_class_extract.R
\name{dec_mutations_count}
\alias{dec_mutations_count}
\title{decrement the number of allowed mutations}
\usage{
dec_mutations_count(x)
}
\arguments{
\item{x}{pkg_ref object to decrement mutation counter for}
}
\value{
pkg_ref object
}
\description{
decrement the number of allowed mutations
}
\keyword{internal}
================================================
FILE: man/determine_pkg_source.Rd
================================================
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/pkg_ref_class.R
\name{determine_pkg_source}
\alias{determine_pkg_source}
\title{Determine the intended source of a new package}
\usage{
determine_pkg_source(x, source, repos)
}
\arguments{
\item{x}{Package name or path to package}
\item{source}{type of source passed in `pkg_ref`}
}
\value{
one of c('pkg_source', 'pkg_install', 'pkg_cran_remote',
'pkg_bioc_remote', 'pkg_missing')
}
\description{
Determine the intended source of a new package
}
\keyword{internal}
================================================
FILE: man/dot-tools.Rd
================================================
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/utils.R
\name{.tools}
\alias{.tools}
\title{Accessor for tools namespace}
\usage{
.tools()
}
\value{
tools namespace
}
\description{
used internally for
- tools:::.news_reader_default
}
\keyword{internal}
================================================
FILE: man/examples_from_dir.Rd
================================================
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/pkg_ref_cache_examples.R
\name{examples_from_dir}
\alias{examples_from_dir}
\title{Build logical vector for Rd objects with example or usage fields discovered in a given directory}
\usage{
examples_from_dir(path, pkg)
}
\arguments{
\item{path}{a package directory path expected to contain exported objects}
}
\value{
a numeric proportion of documentation files with examples
}
\description{
Build logical vector for Rd objects with example or usage fields discovered in a given directory
}
\keyword{internal}
================================================
FILE: man/examples_from_pkg.Rd
================================================
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/pkg_ref_cache_examples.R
\name{examples_from_pkg}
\alias{examples_from_pkg}
\title{Build logical vector for Rd objects with example or usage fields discovered in a given package}
\usage{
examples_from_pkg(pkg)
}
\arguments{
\item{pkg}{a package name expected to contain exported objects}
}
\value{
a numeric proportion of documentation files with examples
}
\description{
Build logical vector for Rd objects with example or usage fields discovered in a given package
}
\keyword{internal}
================================================
FILE: man/filter_rd_db.Rd
================================================
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/pkg_ref_cache_examples.R
\name{filter_rd_db}
\alias{filter_rd_db}
\title{Filter a simple database of Rd objects in a package for files with example fields}
\usage{
filter_rd_db(rddb)
}
\arguments{
\item{rddb}{a simple database of Rd object obtained via tools::Rd_db}
}
\value{
a vector of Rd file names that have example fields
}
\description{
Filter a simple database of Rd objects in a package for files with example fields
}
\keyword{internal}
================================================
FILE: man/firstS3method.Rd
================================================
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/utils.R
\name{firstS3method}
\alias{firstS3method}
\title{Find the S3 method that will be evaluated when an S3 generic is called by
an object of class \code{classes}}
\usage{
firstS3method(f, classes, envir = parent.frame())
}
\arguments{
\item{f}{a character string giving the name of the generic.}
\item{classes}{a character vector of classes used to search for the
appropriate S3 method}
\item{envir}{the \code{\link{environment}} in which the method and its
generic are searched first.}
}
\value{
a S3 method
}
\description{
Find the S3 method that will be evaluated when an S3 generic is called by
an object of class \code{classes}
}
\keyword{internal}
================================================
FILE: man/format_assessment_message.Rd
================================================
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/pkg_metric_error.R
\name{format_assessment_message}
\alias{format_assessment_message}
\title{Assessment console printing formatter}
\usage{
format_assessment_message(e, name, assessment)
}
\arguments{
\item{e}{an error raised during a package reference assessment}
\item{name}{the name of the package whose package reference assessment raised
the error}
\item{assessment}{the name of the assessment function which raised the error}
}
\value{
a character string of formatted text to communicate the error
}
\description{
make the errors and warnings consistent with meaningful indication of what
triggered the error, including the name of the package whose reference
triggered the error while running which asesessment.
}
\keyword{internal}
================================================
FILE: man/get_assessment_columns.Rd
================================================
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/pkg_assess.R
\name{get_assessment_columns}
\alias{get_assessment_columns}
\title{Helper for retrieving a list of columns which contain pkg_metric objects}
\usage{
get_assessment_columns(tbl)
}
\arguments{
\item{tbl}{a \code{\link[tibble]{tibble}} to select columns among}
}
\value{
a logical vector of \code{pkg_metric} column indices
}
\description{
Helper for retrieving a list of columns which contain pkg_metric objects
}
\keyword{internal}
================================================
FILE: man/get_assessments.Rd
================================================
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/pkg_assess.R
\name{get_assessments}
\alias{get_assessments}
\title{Get a specific set of assess_* functions for pkg_assess}
\usage{
get_assessments(fxn_string = "")
}
\arguments{
\item{fxn_string}{vector of assess functions}
}
\value{
a list of specific assess_* functions exported from riskmetric
}
\description{
Get a specific set of assess_* functions for pkg_assess
}
================================================
FILE: man/get_package_dependencies.Rd
================================================
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/assess_dependencies.R
\name{get_package_dependencies}
\alias{get_package_dependencies}
\title{Gets available packages from necessary repository and filters for
package of interest}
\usage{
get_package_dependencies(name, repo)
}
\arguments{
\item{name}{package name}
\item{repo}{package repository (e.g. CRAN or Bioconductor)}
}
\value{
Returns a data frame with two columns 1) Package names, 2) type of dependency (LinkingTo, Imports, Depends)
}
\description{
Gets available packages from necessary repository and filters for
package of interest
}
\keyword{internal}
================================================
FILE: man/get_pkg_ref_classes.Rd
================================================
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/pkg_ref_class.R
\name{get_pkg_ref_classes}
\alias{get_pkg_ref_classes}
\title{Walk the pkg_ref class hierarchy to match a single subclass to a class path}
\usage{
get_pkg_ref_classes(x, classes = pkg_ref_class_hierarchy)
}
\arguments{
\item{x}{(`character(1L)`) A subclass, among those known in pkg_ref subclasses}
\item{classes}{(`list`) A class hierarchy, described using a named list.
Defaults to `pkg_ref_class_hierarchy`.}
}
\value{
A `character(n)` class path from `pkg_ref` down to the specified
subclass, or `FALSE` if no path is found.
}
\description{
Walk the pkg_ref class hierarchy to match a single subclass to a class path
}
\keyword{internal}
================================================
FILE: man/if_not_null_else.Rd
================================================
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/utils.R
\name{if_not_null_else}
\alias{if_not_null_else}
\alias{\%||\%}
\title{If not NULL else}
\usage{
lhs \%||\% rhs
}
\arguments{
\item{lhs}{Left-hand side}
\item{rhs}{Right-hand side
A shorthand for a common comparison}
}
\value{
an object same as \code{lhs} or \code{rhs}
}
\description{
If not NULL else
}
\keyword{internal}
================================================
FILE: man/inc_mutations_count.Rd
================================================
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/pkg_ref_class_extract.R
\name{inc_mutations_count}
\alias{inc_mutations_count}
\title{increment the number of allowed mutations}
\usage{
inc_mutations_count(x)
}
\arguments{
\item{x}{pkg_ref object to increment mutation counter for}
}
\value{
a pkg_ref object
}
\description{
increment the number of allowed mutations
}
\keyword{internal}
================================================
FILE: man/is_url_subpath_of.Rd
================================================
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/utils.R
\name{is_url_subpath_of}
\alias{is_url_subpath_of}
\title{check if a url originates from a list of repo urls}
\usage{
is_url_subpath_of(url, urls)
}
\arguments{
\item{url}{a url which may stem from one of the provided base urls}
\item{urls}{vector of base urls}
}
\value{
logical vector indicating which base urls have a sub url of
\code{url}
}
\description{
check if a url originates from a list of repo urls
}
\keyword{internal}
================================================
FILE: man/memoise_bioc_mirrors.Rd
================================================
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/utils_memoised.R
\name{memoise_bioc_mirrors}
\alias{memoise_bioc_mirrors}
\title{Fetch BioC Mirrors Info}
\usage{
memoise_bioc_mirrors()
}
\value{
a data frame with mirror information
}
\description{
taken from utils::chooseBioCmirror
}
\keyword{internal}
================================================
FILE: man/memoise_cran_mirrors.Rd
================================================
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/utils_memoised.R
\name{memoise_cran_mirrors}
\alias{memoise_cran_mirrors}
\title{Fetch CRAN Mirrors Info}
\usage{
memoise_cran_mirrors(all = TRUE, ..., .local = getOption("riskmetric.tests"))
}
\arguments{
\item{all}{default \code{TRUE}, passed to \code{\link{utils}[getCRANmirrors]}}
\item{...}{additional arguments passed to \code{\link{utils}[getCRANmirrors]}}
\item{.local}{an optional local directory to source the CRAN package index
from, defaulting to \code{getOption("riskmetric.tests")}, used
for isolating repository requests during testing.}
}
\value{
a data frame with mirror information
}
\description{
Fetch CRAN Mirrors Info
}
\keyword{internal}
================================================
FILE: man/metric_score.Rd
================================================
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/metric_score.R
\name{metric_score}
\alias{metric_score}
\title{Score a package metric}
\usage{
metric_score(x, ...)
}
\arguments{
\item{x}{A \code{pkg_metric_*} class object to score}
\item{...}{Additional arguments unused}
}
\value{
score of a package risk metric
}
\description{
Convert a package metric into a numeric value between 0 to 1
}
================================================
FILE: man/metric_score.pkg_metric_covr_coverage.Rd
================================================
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/assess_covr_coverage.R
\name{metric_score.pkg_metric_covr_coverage}
\alias{metric_score.pkg_metric_covr_coverage}
\title{Score a package for unit test coverage}
\usage{
\method{metric_score}{pkg_metric_covr_coverage}(x, ...)
}
\arguments{
\item{x}{a \code{pkg_metric_covr_coverage} packge metric object}
\item{...}{additional arguments unused}
}
\value{
A \code{numeric}
}
\description{
Returns the overall test coverage from a covr coverage report
}
\examples{
\dontrun{metric_score(assess_covr_coverage(pkg_ref("riskmetric")))
}
}
================================================
FILE: man/metric_score.pkg_metric_dependencies.Rd
================================================
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/assess_dependencies.R
\name{metric_score.pkg_metric_dependencies}
\alias{metric_score.pkg_metric_dependencies}
\title{Score a package for dependencies}
\usage{
\method{metric_score}{pkg_metric_dependencies}(x, ...)
}
\arguments{
\item{x}{a \code{pkg_metric_dependencies} packge metric object}
\item{...}{additional arguments unused}
}
\value{
numeric value between \code{0} (high number of dependencies) and
\code{1} (low number of dependencies)
}
\description{
Calculates a regularized score based on the number of dependencies a package has.
Convert the number of dependencies \code{NROW(x)} into a validation
score [0,1] \deqn{ 1 - 1 / (1 + exp(-0.5 * (NROW(x) + 4))) }
}
\details{
The scoring function is the classic logistic curve \deqn{ / (1 + exp(-k(x-x[0])) }
\eqn{x = NROW(x)}, sigmoid midpoint is 5 reverse dependencies, ie. \eqn{x[0] = 4},
and logistic growth rate of \eqn{k = 0.5}.
\deqn{ 1 - 1 / (1 + exp(NROW(x)-4)) }
}
\examples{
\dontrun{metric_score(assess_dependencies(pkg_ref("riskmetric")))
}
}
================================================
FILE: man/metric_score.pkg_metric_downloads_1yr.Rd
================================================
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/assess_downloads.R
\name{metric_score.pkg_metric_downloads_1yr}
\alias{metric_score.pkg_metric_downloads_1yr}
\title{Defining an Assessment Scoring Function}
\usage{
\method{metric_score}{pkg_metric_downloads_1yr}(x, ...)
}
\arguments{
\item{x}{a \code{pkg_metric_downloads_1yr} packge metric object}
\item{...}{additional arguments unused}
}
\value{
numeric value between \code{0} (low) and \code{1} (high download
volume) converting the number of downloads.
}
\description{
Score a package for the number of downloads in the past year regularized
Convert the number of downloads \code{x} in the past year into a validation
score [0,1] \deqn{ 1 - 150,000 / (x + 150,000) }
}
\details{
The scoring function is a simplification of the classic logistic curve \deqn{
1 / (1 + exp(-k(x-x[0])) } with a log scale for the number of downloads
\eqn{x = log(x)}, sigmoid midpoint is 1000 downloads, ie. \eqn{x[0] =
log(1,000)}, and logistic growth rate of \eqn{k = 0.5}.
\deqn{ 1 - 1 / (1 + exp(log(x)-log(1.5e5))) = 1 - 150,000 / (x + 150,000) }
}
\examples{
\dontrun{metric_score(assess_downloads_1yr(pkg_ref("riskmetric")))
}
}
================================================
FILE: man/metric_score.pkg_metric_export_help.Rd
================================================
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/assess_export_help.R
\name{metric_score.pkg_metric_export_help}
\alias{metric_score.pkg_metric_export_help}
\title{Score a package for availability of documentation for exported values}
\usage{
\method{metric_score}{pkg_metric_export_help}(x, ...)
}
\arguments{
\item{x}{a \code{pkg_metric_export_help} packge metric object}
\item{...}{additional arguments unused}
}
\value{
\code{1} if any NEWS files are found, otherwise \code{0}
}
\description{
Coerce a logical vector indicating availability of export documentation
}
\examples{
\dontrun{metric_score(assess_export_help(pkg_ref("riskmetric")))
}
}
================================================
FILE: man/metric_score.pkg_metric_exported_namespace.Rd
================================================
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/assess_exported_namespace.R
\name{metric_score.pkg_metric_exported_namespace}
\alias{metric_score.pkg_metric_exported_namespace}
\title{Score a package for the number of exported objects}
\usage{
\method{metric_score}{pkg_metric_exported_namespace}(x, ...)
}
\arguments{
\item{x}{a \code{pkg_metric_exported_namespace} packge metric object}
\item{...}{additional arguments unused}
}
\value{
numeric value between \code{0} (high number of exported objects) and
\code{1} (low number of exported objects)
}
\description{
Score a package for the number of exported objects it has; regularized
Convert the number of exported objects \code{length(x)} into a validation
score [0,1] \deqn{ 1 / (1 + exp(-0.5 * (sqrt(length(x)) + sqrt(5)))) }
}
\details{
The scoring function is the classic logistic curve \deqn{
1 / (1 + exp(-k(x-x[0])) } with a square root scale for the number of exported objects
\eqn{x = sqrt(length(x))}, sigmoid midpoint is 25 exported objects, ie. \eqn{x[0] =
sqrt(5)}, and logistic growth rate of \eqn{k = 0.25}.
\deqn{ 1 / (1 + exp(-0.25 * sqrt(length(x))-sqrt(25))) }
}
\examples{
\dontrun{metric_score(assess_exported_namespace(pkg_ref("riskmetric")))
}
}
================================================
FILE: man/metric_score.pkg_metric_has_bug_reports_url.Rd
================================================
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/assess_has_bug_reports_url.R
\name{metric_score.pkg_metric_has_bug_reports_url}
\alias{metric_score.pkg_metric_has_bug_reports_url}
\title{Score a package for the presence of a bug report url}
\usage{
\method{metric_score}{pkg_metric_has_bug_reports_url}(x, ...)
}
\arguments{
\item{x}{a \code{pkg_metric_has_bug_reports_url} packge metric object}
\item{...}{additional arguments unused}
}
\value{
A logical value indicating whether the package has a BugReports field
filled in
}
\description{
Score a package for the presence of a bug report url
}
\examples{
\dontrun{metric_score(assess_has_bug_reports_url(pkg_ref("riskmetric")))
}
}
================================================
FILE: man/metric_score.pkg_metric_has_examples.Rd
================================================
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/assess_has_examples.R
\name{metric_score.pkg_metric_has_examples}
\alias{metric_score.pkg_metric_has_examples}
\title{Score a package for the presence of a example or usage fields}
\usage{
\method{metric_score}{pkg_metric_has_examples}(x, ...)
}
\arguments{
\item{x}{a \code{pkg_metric_has_examples} packge metric object}
\item{...}{additional arguments unused}
}
\value{
\code{1} if any example or usage fields are found, otherwise \code{0}
}
\description{
Coerce a logical vector indicating availability of example or usage documentation
}
\examples{
\dontrun{metric_score(assess_has_examples(pkg_ref("riskmetric")))
}
}
================================================
FILE: man/metric_score.pkg_metric_has_maintainer.Rd
================================================
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/assess_has_maintainer.R
\name{metric_score.pkg_metric_has_maintainer}
\alias{metric_score.pkg_metric_has_maintainer}
\title{Score a package for inclusion of an associated maintainer}
\usage{
\method{metric_score}{pkg_metric_has_maintainer}(x, ...)
}
\arguments{
\item{x}{a \code{pkg_metric_has_maintainer} packge metric object}
\item{...}{additional arguments unused}
}
\value{
\code{1} if any maintainer is provided, otherwise \code{0}
}
\description{
Coerce a list of maintainers into a numeric value indicating whether the
number of listed maintainers is greater than 0.
}
\examples{
\dontrun{metric_score(assess_has_maintainer(pkg_ref("riskmetric")))
}
}
================================================
FILE: man/metric_score.pkg_metric_has_news.Rd
================================================
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/assess_has_news.R
\name{metric_score.pkg_metric_has_news}
\alias{metric_score.pkg_metric_has_news}
\title{Score a package for the presence of a NEWS file}
\usage{
\method{metric_score}{pkg_metric_has_news}(x, ...)
}
\arguments{
\item{x}{a \code{pkg_metric_has_news} packge metric object}
\item{...}{additional arguments unused}
}
\value{
\code{1} if any NEWS files are found, otherwise \code{0}
}
\description{
Coerce the number of news files to binary indication of valid NEWS files
}
\examples{
\dontrun{metric_score(assess_has_news(pkg_ref("riskmetric")))
}
}
================================================
FILE: man/metric_score.pkg_metric_has_source_control.Rd
================================================
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/assess_has_source_control.R
\name{metric_score.pkg_metric_has_source_control}
\alias{metric_score.pkg_metric_has_source_control}
\title{Score a package for inclusion of an associated source control url}
\usage{
\method{metric_score}{pkg_metric_has_source_control}(x, ...)
}
\arguments{
\item{x}{a \code{pkg_metric_has_source_control} packge metric object}
\item{...}{additional arguments unused}
}
\value{
\code{1} if any source control url is provided, otherwise \code{0}
}
\description{
Coerce a list of source control urls into a numeric value indicating whether
the number of listed urls is greater than 0.
}
\examples{
\dontrun{metric_score(assess_has_source_control(pkg_ref("riskmetric")))
}
}
================================================
FILE: man/metric_score.pkg_metric_has_vignettes.Rd
================================================
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/assess_has_vignettes.R
\name{metric_score.pkg_metric_has_vignettes}
\alias{metric_score.pkg_metric_has_vignettes}
\title{Score a package for the presence of a Vignettes file}
\usage{
\method{metric_score}{pkg_metric_has_vignettes}(x, ...)
}
\arguments{
\item{x}{a \code{pkg_metric_has_vignettes} packge metric object}
\item{...}{additional arguments unused}
}
\value{
\code{1} if any Vignettes files are found, otherwise \code{0}
}
\description{
Coerce the number of vignettes files to binary indication of valid Vignettes
}
\examples{
\dontrun{metric_score(assess_has_vignettes(pkg_ref("riskmetric")))
}
}
================================================
FILE: man/metric_score.pkg_metric_has_website.Rd
================================================
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/assess_has_website.R
\name{metric_score.pkg_metric_has_website}
\alias{metric_score.pkg_metric_has_website}
\title{Score a package for inclusion of an associated website url}
\usage{
\method{metric_score}{pkg_metric_has_website}(x, ...)
}
\arguments{
\item{x}{a \code{pkg_metric_has_website} packge metric object}
\item{...}{additional arguments unused}
}
\value{
\code{1} if any website url is provided, otherwise \code{0}
}
\description{
Coerce a list of website urls into a numeric value indicating whether the
number of listed urls is greater than 0.
}
\examples{
\dontrun{metric_score(assess_has_website(pkg_ref("riskmetric")))
}
}
================================================
FILE: man/metric_score.pkg_metric_last_30_bugs_status.Rd
================================================
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/assess_last_30_bugs_status.R
\name{metric_score.pkg_metric_last_30_bugs_status}
\alias{metric_score.pkg_metric_last_30_bugs_status}
\title{Score a package for number of recently opened BugReports that are now closed}
\usage{
\method{metric_score}{pkg_metric_last_30_bugs_status}(x, ...)
}
\arguments{
\item{x}{a \code{pkg_metric_last_30_bugs_status} packge metric object}
\item{...}{additional arguments unused}
}
\value{
a fractional value indicating percentage of last 30 bug reports that
are now closed
}
\description{
Score a package for number of recently opened BugReports that are now closed
}
\examples{
\dontrun{metric_score(assess_last_30_bugs_status(pkg_ref("riskmetric")))
}
}
================================================
FILE: man/metric_score.pkg_metric_license.Rd
================================================
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/assess_license.R
\name{metric_score.pkg_metric_license}
\alias{metric_score.pkg_metric_license}
\title{Score a package for acceptable license}
\usage{
\method{metric_score}{pkg_metric_license}(x, ...)
}
\arguments{
\item{x}{a \code{pkg_metric_license} packge metric object}
\item{...}{additional arguments unused}
}
\value{
score of metric license
}
\description{
Maps a license string to a score
}
\examples{
\dontrun{metric_score(assess_license(pkg_ref("riskmetric")))
}
}
================================================
FILE: man/metric_score.pkg_metric_news_current.Rd
================================================
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/assess_news_current.R
\name{metric_score.pkg_metric_news_current}
\alias{metric_score.pkg_metric_news_current}
\title{Score a package for NEWS files updated to current version}
\usage{
\method{metric_score}{pkg_metric_news_current}(x, ...)
}
\arguments{
\item{x}{a \code{pkg_metric_news_current} packge metric object}
\item{...}{additional arguments unused}
}
\value{
\code{1} if any NEWS files are up-to-date, otherwise \code{0}
}
\description{
Coerce a logical vector of discovered up-to-date NEWS to a metric score
}
\examples{
\dontrun{metric_score(assess_news_current(pkg_ref("riskmetric")))
}
}
================================================
FILE: man/metric_score.pkg_metric_r_cmd_check.Rd
================================================
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/assess_r_cmd_check.R
\name{metric_score.pkg_metric_r_cmd_check}
\alias{metric_score.pkg_metric_r_cmd_check}
\title{Score a package based on R CMD check results run locally}
\usage{
\method{metric_score}{pkg_metric_r_cmd_check}(x, ...)
}
\arguments{
\item{x}{a \code{pkg_metric_r_cmd_check} packge metric object}
\item{...}{additional arguments unused}
}
\value{
A weighted sum of errors and warnings of all tests preformed
}
\description{
The scoring function is the weighted sum of notes (0.1), errors (1) and warnings (0.25), with a maximum score of 1 (no errors, notes or warnings)
and a minimum score of 0.
Essentially, the metric will allow up to 10 notes, 1 error or 4 warnings before returning the lowest score of 0
}
\examples{
\dontrun{metric_score(assess_r_cmd_check(pkg_ref("riskmetric")))
}
}
================================================
FILE: man/metric_score.pkg_metric_remote_checks.Rd
================================================
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/assess_remote_checks.R
\name{metric_score.pkg_metric_remote_checks}
\alias{metric_score.pkg_metric_remote_checks}
\title{Score a package based on R CMD check results run by BioC or CRAN}
\usage{
\method{metric_score}{pkg_metric_remote_checks}(x, ...)
}
\arguments{
\item{x}{a \code{pkg_metric_remote_checks} packge metric object}
\item{...}{additional arguments unused}
}
\value{
a fractional value indicating percentage OS flavors that did not produce an error or warning from R CMD check
}
\description{
The scoring function is the number of OS flavors that passed with OK or NOTES + 0.5*the number of OS's that produced WARNINGS divided by the number of OS's checked
}
\examples{
\dontrun{metric_score(assess_remote_checks(pkg_ref("riskmetric")))
}
}
================================================
FILE: man/metric_score.pkg_metric_reverse_dependencies.Rd
================================================
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/assess_reverse_dependencies.R
\name{metric_score.pkg_metric_reverse_dependencies}
\alias{metric_score.pkg_metric_reverse_dependencies}
\title{Scoring method for number of reverse dependencies a package has}
\usage{
\method{metric_score}{pkg_metric_reverse_dependencies}(x, ...)
}
\arguments{
\item{x}{a \code{pkg_metric_reverse_dependencies} packge metric object}
\item{...}{additional arguments unused}
}
\value{
numeric value between \code{1} (high number of reverse dependencies) and
\code{0} (low number of reverse dependencies)
}
\description{
Score a package for the number of reverse dependencies it has; regularized
Convert the number of reverse dependencies \code{length(x)} into a validation
score [0,1] \deqn{ 1 / (1 + exp(-0.5 * (sqrt(length(x)) + sqrt(5)))) }
}
\details{
The scoring function is the classic logistic curve \deqn{
1 / (1 + exp(-k(x-x[0])) } with a square root scale for the number of reverse dependencies
\eqn{x = sqrt(length(x))}, sigmoid midpoint is 5 reverse dependencies, ie. \eqn{x[0] =
sqrt(5)}, and logistic growth rate of \eqn{k = 0.5}.
\deqn{ 1 / (1 + -0.5 * exp(sqrt(length(x)) - sqrt(5))) }
}
\examples{
\dontrun{metric_score(assess_reverse_dependencies(pkg_ref("riskmetric")))
}
}
================================================
FILE: man/metric_score.pkg_metric_size_codebase.Rd
================================================
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/assess_size_codebase.R
\name{metric_score.pkg_metric_size_codebase}
\alias{metric_score.pkg_metric_size_codebase}
\title{Score a package for number of lines of code}
\usage{
\method{metric_score}{pkg_metric_size_codebase}(x, ...)
}
\arguments{
\item{x}{a \code{pkg_metric_size_codebase} packge metric object}
\item{...}{additional arguments unused}
}
\value{
numeric value between \code{0} (for large codebase) and \code{1} (for small codebase)
}
\description{
Scores packages based on its codebase size, as determined by number of lines of code.
}
\examples{
\dontrun{metric_score(assess_size_codebase(pkg_ref("riskmetric")))
}
}
================================================
FILE: man/news_from_dir.Rd
================================================
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/pkg_ref_cache_news.R
\name{news_from_dir}
\alias{news_from_dir}
\title{Build a list of NEWS files discovered within a given directory}
\usage{
news_from_dir(path)
}
\arguments{
\item{path}{a package directory path expected to contain NEWS files}
}
\value{
a list of parsed NEWS files
}
\description{
Build a list of NEWS files discovered within a given directory
}
\keyword{internal}
================================================
FILE: man/parse_dcf_dependencies.Rd
================================================
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/assess_dependencies.R
\name{parse_dcf_dependencies}
\alias{parse_dcf_dependencies}
\title{Parse DCF of description file}
\usage{
parse_dcf_dependencies(path)
}
\arguments{
\item{path}{pkg_ref path}
}
\description{
Parse DCF of description file
}
\keyword{internal}
================================================
FILE: man/pkg_assess.Rd
================================================
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/pkg_assess.R
\name{pkg_assess}
\alias{pkg_assess}
\title{Apply assess_* family of functions to a package reference}
\usage{
pkg_assess(
x,
assessments = all_assessments(),
...,
error_handler = assessment_error_empty
)
}
\arguments{
\item{x}{A single \code{\link{pkg_ref}} object or
\code{\link[tibble]{tibble}} of package references to assess}
\item{assessments}{A list of assessment functions to apply to each package
reference. By default, a list of all exported assess_* functions from the
riskmetric package.}
\item{...}{additional arguments unused}
\item{error_handler}{A function, which accepts a single parameter expecting
the raised error, which will be called if any errors occur when attempting
to apply an assessment function.}
}
\value{
Either a \code{list_of_pkg_metric} object when a single
\code{pkg_ref} object is passed as \code{x}, or a
\code{\link[tibble]{tibble}} of metrics when a \code{list_of_pkg_ref} or
\code{tibble} is passed as \code{x}. When a \code{\link[tibble]{tibble}}
is returned, it has one row per package reference and a new column per
assessment function, with cells of that column as package metric objects
returned when the assessment was called with the associated pacakge
reference.
}
\description{
By default, use all \code{assess_*} funtions in the \code{riskmetric}
namespace and produce a \code{\link[tibble]{tibble}} with one column per
assessment applied.
}
\section{Assessment function catalog}{
\describe{
\item{\code{\link{assess_covr_coverage}}}{Package unit test coverage}
\item{\code{\link{assess_has_news}}}{number of discovered NEWS files}
\item{\code{\link{assess_remote_checks}}}{Number of OS flavors that passed/warned/errored on R CMD check}
\item{\code{\link{assess_news_current}}}{NEWS file contains entry for current version number}
\item{\code{\link{assess_r_cmd_check}}}{Package check results}
\item{\code{\link{assess_exported_namespace}}}{Objects exported by package}
\item{\code{\link{assess_has_vignettes}}}{number of discovered vignettes files}
\item{\code{\link{assess_export_help}}}{exported objects have documentation}
\item{\code{\link{assess_has_website}}}{a vector of associated website urls}
\item{\code{\link{assess_has_maintainer}}}{a vector of associated maintainers}
\item{\code{\link{assess_last_30_bugs_status}}}{vector indicating whether BugReports status is closed}
\item{\code{\link{assess_size_codebase}}}{number of lines of code base}
\item{\code{\link{assess_has_source_control}}}{a vector of associated source control urls}
\item{\code{\link{assess_has_bug_reports_url}}}{presence of a bug reports url in repository}
\item{\code{\link{assess_downloads_1yr}}}{number of downloads in the past year}
\item{\code{\link{assess_reverse_dependencies}}}{List of reverse dependencies a package has}
\item{\code{\link{assess_has_examples}}}{proportion of discovered function files with examples}
\item{\code{\link{assess_dependencies}}}{Package dependency footprint}
\item{\code{\link{assess_license}}}{software is released with an acceptable license}
}
}
================================================
FILE: man/pkg_metric.Rd
================================================
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/pkg_metric.R
\name{pkg_metric}
\alias{pkg_metric}
\title{A helper for structuring assessment return objects for dispatch with the
score function}
\usage{
pkg_metric(x = NA, ..., class = c())
}
\arguments{
\item{x}{data to store as a \code{pkg_metric}}
\item{...}{additional attributes to bind to the \code{pkg_metric} object}
\item{class}{a subclass to differentiate the \code{pkg_metric} object}
}
\value{
a \code{pkg_metric} object
}
\description{
A helper for structuring assessment return objects for dispatch with the
score function
}
================================================
FILE: man/pkg_metric_eval.Rd
================================================
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/pkg_metric.R
\name{pkg_metric_eval}
\alias{pkg_metric_eval}
\title{Evaluate a metric}
\usage{
pkg_metric_eval(expr, ..., class = c(), env = parent.frame())
}
\arguments{
\item{expr}{An expression to evaluate in order to calculate a
\code{pkg_metric}}
\item{...}{additional attributes to bind to the \code{pkg_metric} object}
\item{class}{a subclass to differentiate the \code{pkg_metric} object}
\item{env}{An environment in which \code{expr} is to be evaluated}
}
\value{
a \code{pkg_metric} object containing the result of \code{expr}
}
\description{
Evalute code relevant to a metric, capturing the evaluated code as well as
any messages, warnings or errors that are thrown in the process.
}
\keyword{internal}
================================================
FILE: man/pkg_ref.Rd
================================================
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/pkg_ref_class.R
\name{pkg_ref}
\alias{pkg_ref}
\alias{pkg_install}
\alias{pkg_source}
\alias{pkg_cran}
\alias{pkg_bioc}
\alias{pkg_missing}
\alias{pkg_library}
\alias{as_pkg_ref}
\title{Create a package reference}
\usage{
pkg_ref(x, ...)
pkg_install(x, lib.loc = NULL)
pkg_source(x)
pkg_cran(x, repos = getOption("repos", "https://cran.rstudio.com"))
pkg_bioc(x)
pkg_missing(x)
pkg_library(lib.loc)
as_pkg_ref(x, ...)
}
\arguments{
\item{x}{A singular \code{character} value, \code{character vector} or
\code{list} of \code{character} values of package names or source code
directory paths.}
\item{...}{Additional arguments passed to methods.}
\item{lib.loc}{The path to the R library directory of the installed package.}
\item{repos}{URL of CRAN repository to pull package metadata.}
}
\value{
When a single value is provided, a single \code{pkg_ref} object is
returned, possibly with a subclass based on where the package was found. If
a \code{vector} or \code{list} is provided, a \code{list_of_pkg_ref} object
constructed with \code{\link[vctrs]{list_of}} is returned, which can be
considered analogous to a \code{list}. See 'Details' for further
information about \code{pkg_ref} subclasses.
}
\description{
Create a package reference from package name or filepath, producing an object
in which package metadata will be collected as risk assessments are
performed. Depending on where the package was found - whether it is found as
source code, in a local library or from a remote host - an S3 subclass is
given to allow for source-specific collection of metadata. See 'Details' for
a breakdown of subclasses. Different sources can be specified by passing a
subclass as an arguemnt named 'source', see details.
}
\details{
Package reference objects are used to collect metadata pertaining to a given
package. As data is needed for assessing a package's risk, this metadata
populates fields within the package reference object.
The \code{pkg_ref} S3 subclasses are used extensively for divergent metadata
collection behaviors dependent on where the package was discovered. Because
of this, there is a rich hierarchy of subclasses to articulate the different
ways package information can be found.
A source argument can be passed using the `source` argument. This will
override the logic that riskmetric does when determining a package source.
This can be useful when you are scoring the most recent version present on a
repository, or testing a specific library.
\describe{
\item{\strong{\code{pkg_ref}}}{ A default class for general metadata
collection.}
\item{\strong{\code{pkg_source}}}{ A reference to a source code
directory.}
\item{\strong{\code{pkg_install}}}{ A reference to a package installation
location in a package library. A specific library can be passed by
passing the path to the library as the parameter `lib.loc`}
\item{\strong{\code{pkg_remote}}}{ A reference to package metadata on a
remote server.
\describe{
\item{\strong{\code{pkg_cran_remote}}}{ A reference to package
information pulled from the CRAN repository.}
\item{\strong{\code{pkg_bioc_remote}}}{ A reference to package
information pulled from the Bioconductor repository.}
\item{\strong{\code{pkg_git_remote}}}{ A reference to a package source
code git repository. (not yet implemented)}
}
}
}
}
\section{Package Cohorts}{
*Experimental!*
Package cohorts are structures to determine the risk of a set of packages.
`pkg_library()` can be called to create a object containing the pkg_ref
objects of all packages in a system library.
}
\examples{
\dontrun{
# riskmetric will check for installed packages by default
ref_1 <- pkg_ref("utils")
ref_1$source # returns 'pkg_install'
# lib.loc can be used to specify a library for pkg_install
ref_3 <- pkg_ref("utils", source = "pkg_install", lib.loc = .libPaths()[1])
# You can also override this behavior with a source argument
ref_2 <- pkg_ref("utils", source = "pkg_cran_remote")
ref_2$source # returns 'pkg_cran_remote'
}
}
================================================
FILE: man/pkg_ref_cache.bug_reports_host.default.Rd
================================================
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/pkg_ref_cache_bug_reports_host.R
\name{pkg_ref_cache.bug_reports_host.default}
\alias{pkg_ref_cache.bug_reports_host.default}
\title{Get the host name of a BugReports url}
\usage{
\method{pkg_ref_cache}{bug_reports_host.default}(x, ...)
}
\value{
a \code{pkg_ref} object
}
\description{
Get the host name of a BugReports url
}
\keyword{internal}
================================================
FILE: man/pkg_ref_cache.bug_reports_url.pkg_source.Rd
================================================
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/pkg_ref_cache_bug_reports_url.R
\name{pkg_ref_cache.bug_reports_url.pkg_source}
\alias{pkg_ref_cache.bug_reports_url.pkg_source}
\title{Get the BugReports url}
\usage{
\method{pkg_ref_cache}{bug_reports_url.pkg_source}(x, ...)
}
\value{
a \code{pkg_ref} object
}
\description{
Get the BugReports url
}
\keyword{internal}
================================================
FILE: man/pkg_ref_cache.covr_coverage.pkg_source.Rd
================================================
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/pkg_ref_cache_covr_coverage.R
\name{pkg_ref_cache.covr_coverage.pkg_source}
\alias{pkg_ref_cache.covr_coverage.pkg_source}
\title{Retrieve output of covr::package_coverage}
\usage{
\method{pkg_ref_cache}{covr_coverage.pkg_source}(x, ...)
}
\value{
a \code{pkg_ref} object
}
\description{
Retrieve output of covr::package_coverage
}
\keyword{internal}
================================================
FILE: man/pkg_ref_cache.expression_coverage.pkg_source.Rd
================================================
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/pkg_ref_cache_expr_coverage.R
\name{pkg_ref_cache.expression_coverage.pkg_source}
\alias{pkg_ref_cache.expression_coverage.pkg_source}
\title{Retrieve output of covr::package_coverage, tallied by expression}
\usage{
\method{pkg_ref_cache}{expression_coverage.pkg_source}(x, ...)
}
\value{
a \code{pkg_ref} object
}
\description{
Retrieve output of covr::package_coverage, tallied by expression
}
\keyword{internal}
================================================
FILE: man/pkg_ref_cache.help.pkg_install.Rd
================================================
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/pkg_ref_cache_help.R
\name{pkg_ref_cache.help.pkg_install}
\alias{pkg_ref_cache.help.pkg_install}
\title{Cache a list of available help files as LaTeX objects}
\usage{
\method{pkg_ref_cache}{help.pkg_install}(x, name, ...)
}
\value{
a \code{pkg_ref} object
}
\description{
Cache a list of available help files as LaTeX objects
}
\keyword{internal}
================================================
FILE: man/pkg_ref_cache.help.pkg_source.Rd
================================================
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/pkg_ref_cache_help.R
\name{pkg_ref_cache.help.pkg_source}
\alias{pkg_ref_cache.help.pkg_source}
\title{Cache a list of available help files as LaTeX objects}
\usage{
\method{pkg_ref_cache}{help.pkg_source}(x, name, ...)
}
\description{
Cache a list of available help files as LaTeX objects
}
\keyword{internal}
================================================
FILE: man/pkg_ref_cache.news.pkg_remote.Rd
================================================
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/pkg_ref_cache_news.R
\name{pkg_ref_cache.news.pkg_remote}
\alias{pkg_ref_cache.news.pkg_remote}
\title{Cache a list of NEWS files from a package reference}
\usage{
\method{pkg_ref_cache}{news.pkg_remote}(x, name, ...)
}
\value{
a \code{pkg_ref} object
}
\description{
Cache a list of NEWS files from a package reference
}
\keyword{internal}
================================================
FILE: man/pkg_ref_class_hierarchy.Rd
================================================
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/pkg_ref_class.R
\docType{data}
\name{pkg_ref_class_hierarchy}
\alias{pkg_ref_class_hierarchy}
\title{The `pkg_ref` subclass hierarchy, used for pkg_ref object creation with a
specified subclass}
\format{
An object of class \code{list} of length 1.
}
\usage{
pkg_ref_class_hierarchy
}
\description{
The `pkg_ref` subclass hierarchy, used for pkg_ref object creation with a
specified subclass
}
\keyword{datasets}
================================================
FILE: man/pkg_ref_mutability_error.Rd
================================================
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/pkg_ref_class_extract.R
\name{pkg_ref_mutability_error}
\alias{pkg_ref_mutability_error}
\title{pretty printing for a pkg_ref mutability error caused by trying to do
assignment within the pkg_ref without permission}
\usage{
pkg_ref_mutability_error(name)
}
\arguments{
\item{name}{name of field for which mutation was attempted}
}
\value{
a \code{simplError} with subclasses \code{pkg_ref_mutability_error},
\code{pkg_ref_error}
}
\description{
pretty printing for a pkg_ref mutability error caused by trying to do
assignment within the pkg_ref without permission
}
\keyword{internal}
================================================
FILE: man/pkg_score.Rd
================================================
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/pkg_score.R
\name{pkg_score}
\alias{pkg_score}
\title{Score a package assessment, collapsing results into a single numeric}
\usage{
pkg_score(x, ..., error_handler = score_error_default)
}
\arguments{
\item{x}{A \code{pkg_metric} object, whose subclass is used to choose the
appropriate scoring method for the atomic metric metadata. Optionally, a
\code{\link[tibble]{tibble}} can be provided, in which cases all
\code{pkg_metric} values will be scored.}
\item{...}{Additional arguments passed to \code{summarize_scores} when an
object of class \code{tbl_df} is provided, unused otherwise.}
\item{error_handler}{Specify a function to be called if the class can't be
identified. Most commonly this occurs for \code{pkg_metric} objects of
subclass \code{pkg_metric_error}, which is produced when an error is
encountered when calculating an associated assessment.}
}
\value{
A numeric value if a single \code{pkg_metric} is provided, or a
\code{\link[tibble]{tibble}} with \code{pkg_metric} objects scored and
returned as numeric values when a \code{\link[tibble]{tibble}} is provided.
}
\description{
pkg_score() calculates the risk involved with using a package. Risk ranges
from 0 (low-risk) to 1 (high-risk).
}
\examples{
\dontrun{
# scoring a single assessment
metric_score(assess_has_news(pkg_ref("riskmetric")))
# scoring many assessments as a tibble
library(dplyr)
pkg_score(pkg_assess(as_tibble(pkg_ref(c("riskmetric", "riskmetric")))))
}
}
\seealso{
score_error_default score_error_zero score_error_NA
}
================================================
FILE: man/print.with_eval_recording.Rd
================================================
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/utils.R
\name{print.with_eval_recording}
\alias{print.with_eval_recording}
\title{Handle pretty printing of expression output}
\usage{
\method{print}{with_eval_recording}(x, playback = FALSE, cr = TRUE, ..., sleep = 0)
}
\arguments{
\item{x}{expr_output to print}
\item{playback}{a \code{logical} indicating whether evaluation output
should be played back (\code{FALSE}), or whether the result value should
be printed as is (\code{TRUE}, the default)}
\item{cr}{a \code{logical} indicating whether carriage returns should be
printed, possibly overwriting characters in the output.}
\item{...}{additional arguments unused}
\item{sleep}{an \code{numeric} indicating a time to sleep between printing
each line to console. This can be helpful if the original output overwrites
valuable information in the log that is eventually overwritten and you
would like to watch it play out as it was formatted.}
}
\value{
a print message
}
\description{
Handle pretty printing of expression output
}
\keyword{internal}
================================================
FILE: man/remove_base_packages.Rd
================================================
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/assess_dependencies.R
\name{remove_base_packages}
\alias{remove_base_packages}
\title{Helper function to remove base and recommended packages}
\usage{
remove_base_packages(df)
}
\arguments{
\item{df}{Data frame of dependencies of a package.}
}
\description{
Helper function to remove base and recommended packages
}
\keyword{internal}
================================================
FILE: man/require_cache_behaviors.Rd
================================================
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/pkg_ref_cache_behaviors.R
\name{require_cache_behaviors}
\alias{require_cache_behaviors}
\title{Stop if a function requires disabled behaviors}
\usage{
require_cache_behaviors(behaviors)
}
\arguments{
\item{behaviors}{a character vector of behavior flags to assert as
requirements for metadata caching. values must have an entry found in
riskmetric:::cache_behaviors list}
}
\value{
a boolean value
}
\description{
Stop if a function requires disabled behaviors
}
\keyword{internal}
================================================
FILE: man/riskmetric.Rd
================================================
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/riskmetric-package.R
\docType{package}
\name{riskmetric}
\alias{riskmetric-package}
\alias{riskmetric}
\title{riskmetric}
\description{
Facilities for assessing R packages against a number of metrics to help
quantify their robustness.
}
\seealso{
Useful links:
\itemize{
\item \url{https://pharmar.github.io/riskmetric/}
\item \url{https://github.com/pharmaR/riskmetric}
\item Report bugs at \url{https://github.com/pharmaR/riskmetric/issues}
}
}
\author{
\strong{Maintainer}: Eli Miller \email{eli.miller@atorusresearch.com}
Authors:
\itemize{
\item R Validation Hub \email{psi.aims.r.validation@gmail.com}
\item Doug Kelkhoff \email{doug.kelkhoff@gmail.com}
\item Marly Gotti
\item Kevin K
\item Yilong Zhang
\item Eric Milliman
\item Juliane Manitz
}
Other contributors:
\itemize{
\item Mark Padgham [contributor]
\item PSI special interest group Application and Implementation of Methodologies in Statistics [copyright holder]
}
}
\keyword{internal}
================================================
FILE: man/riskmetric_metadata_caching.Rd
================================================
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/pkg_ref_cache.R
\name{pkg_ref_cache}
\alias{pkg_ref_cache}
\title{S3 generic to calculate a `pkg_ref` field}
\value{
a \code{pkg_ref} field
}
\description{
Reactively retrieve and cache `pkg_ref` metadata
}
\section{Caching Details}{
\subsection{\code{pkg_ref} class fields}{
The \code{pkg_ref} class structures an environment with special handling
for indexing into the \code{pkg_ref} class using the \code{$} or \code{[[}
operators. For all intents and purposes, the \code{pkg_ref} class is works
conceptually similar to a lazy, immutable \code{list}, and uses the
\code{pkg_ref_cache} function internally to lazily retrieve package
reference fields.
}
\subsection{Lazy metadata caching}{
Laziness in a \code{pkg_ref} object refers to the delayed evaluation of the
contents of its fields. Since some metadata is time or computationally
intensive to retrieve, and unnessary for some assessments, we want to avoid
that retrieval until it is needed.
The first time that a field is accessed within a \code{pkg_ref} object
\code{x}, a corresponding \code{pkg_ref_cache} S3 generic is called. For
example, when \code{x$description} is first accessed, the \code{pkg_ref}
object uses the function \code{pkg_ref_cache.description} to attempt to
retrieve the contents of the corresponding \code{DESCRIPTION} file.
Often, the way that this data is collected might be different depending on
the subclass of the \code{pkg_ref}. In the case of the \code{description}
metadata, a reference to a local install might be able to read in a local
file directly, whereas a reference to a remote source of metadata might
require first downloading the file. For this reason, many
\code{pkg_ref_cache.*} functions are themselves S3 generics that dispatch
on the class of the \code{pkg_ref} object, allowing for divergent behaviors
for different source of package metadata.
}
\subsection{\code{pkg_ref} field immutability}{
Once a field has been calculated, its value is immutable. This behavior was
chosen because of the long time frame over which package metadata changes,
rendering it unnecessary to continually reevaluate fields each time they
are accesssed.
This means that within an assessment, a given field for a package will only
ever be calculated once and preserved for downstream use.
}
}
\examples{
\dontrun{
# implementing a new field called "first_letter" that is consistently derived
# across all pkg_ref objects:
pkg_ref_cache.first_letter <- function(x, name, ...) {
substring(x$name, 1, 1)
}
x <- pkg_ref("riskmetric")
x$first_letter
# implementing a new field called "subclass_enum" that dispatches on
# the subclass of the pkg_ref object:
pkg_ref_cache.subclass_enum <- function(x, name, ...) {
UseMethod("pkg_ref_cache.subclass_enum")
}
pkg_ref_cache.subclass_enum.pkg_ref <- function(x, name, ...) {
0
}
pkg_ref_cache.subclass_enum.pkg_install <- function(x, name, ...) {
1
}
x$subclass_enum
}
}
================================================
FILE: man/roxygen_assess_family.Rd
================================================
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/pkg_assess.R
\name{roxygen_assess_family}
\alias{roxygen_assess_family}
\title{Helper for creating a roxygen header from template for assess_* functions}
\usage{
roxygen_assess_family(
name,
return_type = "an atomic assessment result",
dontrun = TRUE
)
}
\arguments{
\item{name}{the name of the assessment, assuming naming conventions are
followed}
\item{return_type}{an optional added commentary about the return type of the
assessment function}
\item{dontrun}{logical indicating whether examples should be wrapped in
a dontrun block. This is particularly useful for assessments which may
require an internet connection.}
}
\value{
roxygen section template for assess family functions
}
\description{
Helper for creating a roxygen header from template for assess_* functions
}
\examples{
\dontrun{
#' @eval roxygen_assess_family(
#' "has_news",
#' "an integer value indicating the number of discovered NEWS files")
}
}
\keyword{internal}
================================================
FILE: man/roxygen_assess_family_catalog.Rd
================================================
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/pkg_assess.R
\name{roxygen_assess_family_catalog}
\alias{roxygen_assess_family_catalog}
\title{Helper for creating a roxygen itemized list for assess_* functions}
\usage{
roxygen_assess_family_catalog()
}
\value{
roxygen section template for assess family function catalog
}
\description{
Helper for creating a roxygen itemized list for assess_* functions
}
\examples{
\dontrun{
#' @eval assess_family_catalog_roxygen()
}
}
\keyword{internal}
================================================
FILE: man/roxygen_cache_behaviors.Rd
================================================
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/pkg_ref_cache_behaviors.R
\name{roxygen_cache_behaviors}
\alias{roxygen_cache_behaviors}
\title{Document both declare_cache_behavior parameters and options list}
\usage{
roxygen_cache_behaviors(
fmt = "\%s: \%s",
name_fmt = "\%s",
annotation_fmt = "\%s",
wrap_fmt = "\%s",
collapse = "\\n"
)
}
\arguments{
\item{fmt}{format of cache behavior entries}
\item{name_fmt}{special formating for name (first) component}
\item{annotation_fmt}{special formating for annotation (second) component}
\item{wrap_fmt}{a wrapper for the entirety of the roxygen entries}
\item{collapse}{passed to paste}
}
\value{
a string
}
\description{
Document both declare_cache_behavior parameters and options list
}
\keyword{internal}
================================================
FILE: man/roxygen_score_family.Rd
================================================
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/pkg_score.R
\name{roxygen_score_family}
\alias{roxygen_score_family}
\title{Helper for creating a roxygen header from template for score.* functions}
\usage{
roxygen_score_family(name, dontrun = TRUE)
}
\arguments{
\item{name}{the name of the scoring function, assuming naming conventions are
followed}
\item{dontrun}{logical indicating whether examples should be wrapped in
a dontrun block. This is particularly useful for assessments which may
require an internet connection.}
}
\value{
roxygen section template for score family functions
}
\description{
Helper for creating a roxygen header from template for score.* functions
}
\examples{
\dontrun{
#' @eval roxygen_score_family("has_news")
}
}
\keyword{internal}
================================================
FILE: man/score_error_NA.Rd
================================================
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/metric_score.R
\name{score_error_NA}
\alias{score_error_NA}
\title{Score error handler to silently return NA}
\usage{
score_error_NA(...)
}
\arguments{
\item{...}{Additional arguments unused}
}
\value{
a value of package score
}
\description{
Score error handler to silently return NA
}
================================================
FILE: man/score_error_default.Rd
================================================
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/metric_score.R
\name{score_error_default}
\alias{score_error_default}
\title{Default score error handling, emitting a warning and returning 0}
\usage{
score_error_default(x, ...)
}
\arguments{
\item{x}{A \code{pkg_metric_*} class object to score}
\item{...}{Additional arguments unused}
}
\value{
a value of package score
}
\description{
Default score error handling, emitting a warning and returning 0
}
================================================
FILE: man/score_error_zero.Rd
================================================
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/metric_score.R
\name{score_error_zero}
\alias{score_error_zero}
\title{Score error handler to silently return 0}
\usage{
score_error_zero(...)
}
\arguments{
\item{...}{Additional arguments unused}
}
\value{
a value of package score
}
\description{
Score error handler to silently return 0
}
================================================
FILE: man/sub-sub-.pkg_ref.Rd
================================================
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/pkg_ref_class_extract.R
\name{[[.pkg_ref}
\alias{[[.pkg_ref}
\title{Lazily instantiated, immutable metadata access}
\usage{
\method{[[}{pkg_ref}(x, name, ...)
}
\arguments{
\item{x}{pkg_ref object to extract metadata from}
\item{name}{name of metadata field to extract}
\item{...}{additional arguments used to extract from internal environment}
}
\value{
a pkg_ref object
}
\description{
If errors are thrown upon instantiation, they are saved and rethrown any time
the value is attempted to be accessed. These then propegate through
assessment and scoring functions to affect any downstream metrics.
}
\keyword{internal}
================================================
FILE: man/summarize_scores.Rd
================================================
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/summarize_scores.R
\name{summarize_scores}
\alias{summarize_scores}
\title{Summarize a default set of assessments into a single risk score}
\usage{
summarize_scores(data, weights = NULL)
}
\arguments{
\item{data}{a \code{\link[tibble]{tibble}} of scored assessments whose column
names match those provided by riskmetric's \code{\link{pkg_assess}} function.}
\item{weights}{an optional vector of non-negative weights to be assigned to
each assessment.}
}
\value{
a numeric vector of risk scores
}
\description{
This function serves as an example for how a risk score might be derived.
Assuming all assessments provided by \code{riskmetric} are available in a
dataset, this function can be used to calculate a vector of risks.
}
\examples{
\dontrun{
library(dplyr)
summarize_scores(pkg_score(pkg_assess(as_tibble(pkg_ref("riskmetric")))))
library(dplyr)
pkg_ref("riskmetric") \%>\%
pkg_assess() \%>\%
pkg_score() \%>\%
summarize_scores()
}
}
================================================
FILE: man/suppressMatchingConditions.Rd
================================================
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/utils.R
\name{suppressMatchingConditions}
\alias{suppressMatchingConditions}
\title{Suppress messages and warnings based on one or more regex matches}
\usage{
suppressMatchingConditions(expr, ..., .opts = list(), .envir = parent.frame())
}
\arguments{
\item{expr}{An expression to evaluate}
\item{...}{Named parameters, where the name indicates the class of conditions
to capture and the value is a vector of regular expressions that, when
matched against the respective condition message, should suppress that
condition.}
\item{.opts}{A named list of arguments to pass to \code{grepl}}
\item{.envir}{The environment in which \code{expr} is to be evaluated}
}
\value{
a message printed on console
}
\description{
Suppress messages and warnings based on one or more regex matches
}
\keyword{internal}
================================================
FILE: man/use_assessments_column_names.Rd
================================================
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/pkg_assess.R
\name{use_assessments_column_names}
\alias{use_assessments_column_names}
\title{reassign assignment list names with column_name attribute if available}
\usage{
use_assessments_column_names(x)
}
\arguments{
\item{x}{list of columns for which to consider friendly column name
attributes}
}
\value{
a vector of friendly column names if available
}
\description{
reassign assignment list names with column_name attribute if available
}
\keyword{internal}
================================================
FILE: man/verify_pkg_source.Rd
================================================
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/pkg_ref_class.R
\name{verify_pkg_source}
\alias{verify_pkg_source}
\title{Verify a pkg_source when one is manually specified by the user}
\usage{
verify_pkg_source(x, source, repos)
}
\value{
a string of package source
}
\description{
Verify a pkg_source when one is manually specified by the user
}
\keyword{internal}
================================================
FILE: man/vignettes_from_dir.Rd
================================================
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/pkg_ref_cache_vignettes.R
\name{vignettes_from_dir}
\alias{vignettes_from_dir}
\title{Build a List of Vignettes Files Discovered Within a Given Directory}
\usage{
vignettes_from_dir(path)
}
\arguments{
\item{path}{a package directory path expected to contain Vignettes files}
}
\value{
a vector of parsed Vignettes files
}
\description{
Build a List of Vignettes Files Discovered Within a Given Directory
}
\keyword{internal}
================================================
FILE: man/vignettes_from_html.Rd
================================================
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/pkg_ref_cache_vignettes.R
\name{vignettes_from_html}
\alias{vignettes_from_html}
\title{Build a List of Vignettes Files Discovered Within a Package Website}
\usage{
vignettes_from_html(x)
}
\arguments{
\item{x}{a \code{pkg_ref} object}
}
\value{
a vector of Vignettes files
}
\description{
Build a List of Vignettes Files Discovered Within a Package Website
}
\keyword{internal}
================================================
FILE: man/with.pkg_ref.Rd
================================================
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/utils.R
\name{with.pkg_ref}
\alias{with.pkg_ref}
\title{Evaluate an expression in the context of a pkg_ref}
\usage{
\method{with}{pkg_ref}(data, expr, ...)
}
\arguments{
\item{data}{data to use for constructing an environment. For the
default \code{with} method this may be an environment, a list, a
data frame, or an integer as in \code{sys.call}. For \code{within},
it can be a list or a data frame.}
\item{expr}{expression to evaluate; particularly for \code{within()}
often a \dQuote{compound} expression, i.e., of the form \preformatted{ {
a <- somefun()
b <- otherfun()
.....
rm(unused1, temp)
}
}}
\item{...}{arguments to be passed to (future) methods.}
}
\value{
the value of the evaluated expr.
}
\description{
\code{pkg_ref} objects are environments and can be passed to \code{with}
in much the same way. This specialized function makes sure that any fields
within the \code{pkg_ref} have been appropriately evaluated before trying
to execute the expression.
}
\keyword{internal}
================================================
FILE: man/with_unclassed_to.Rd
================================================
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/utils.R
\name{with_unclassed_to}
\alias{with_unclassed_to}
\title{Evaluate an expression after first removing a range of S3 classes}
\usage{
with_unclassed_to(x, .class = 1:length(class(x)), expr, envir = parent.frame())
}
\arguments{
\item{x}{a structured S3-classed object}
\item{.class}{the class to unclass the object to}
\item{expr}{an expression to evaluate, avoiding parent classs dispatch}
\item{envir}{an environment in which the expression is to be evaluated}
}
\value{
the result of \code{expr}
}
\description{
Evaluate an expression after first removing a range of S3 classes
}
\keyword{internal}
================================================
FILE: tests/testthat/setup_mock_web_requests.R
================================================
library(webmockr)
library(httr)
options(riskmetric.tests = test_path())
httr_mock()
# helper function for generating cran-log style API results
build_downloads <- function(downloads = NULL, pkg_name = "temp") {
day = Sys.Date() - seq_along(downloads)
downloads_obj <- list(list(
downloads = rev(mapply(
function(day, dls) list(list(day = day, downloads = dls)),
day,
downloads)),
start = Sys.Date(),
end = Sys.Date() - ifelse(is.null(downloads), 0L, length(downloads)),
package = pkg_name
))
as.character(jsonlite::toJSON(downloads_obj, auto_unbox = TRUE))
}
## CRAN (or mirror) package page
# TODO: separate out good and bad examples
stub_request("get", uri_regex = ".+/web/packages/[^/]*") %>%
to_return(
body = paste(collapse = "\n", readLines(file.path(test_path(), "test_webmocks", "data", "cran_package.html"))),
headers = list(
"Content-Type" = "text/html; charset=utf-8",
"Content-Encoding" = "UTF-8"))
## CRAN (or mirror) package checks page
# TODO: separate out good and bad examples
stub_request("get", uri_regex = ".+/web/checks/[^/]*") %>%
to_return(
body = paste(collapse = "\n", readLines(file.path(test_path(), "test_webmocks", "data", "cran_package_checks.html"))),
headers = list(
"Content-Type" = "text/html; charset=utf-8",
"Content-Encoding" = "UTF-8"))
## CRAN (or mirror) NEWS page
# TODO: separate out good and bad examples
stub_request("get", uri_regex = ".+/web/packages/[^/]*/news/news.html") %>%
to_return(
body = paste(collapse = "\n", readLines(file.path(test_path(), "test_webmocks", "data", "cran_news.html"))),
headers = list(
"Content-Type" = "text/html; charset=utf-8",
"Content-Encoding" = "UTF-8"))
## CRAN (or mirror) package archive listing page
# TODO: serpate out good and bad examples
stub_request("get", uri_regex = ".+/src/contrib/Archive/[^/]*") %>%
to_return(
body = paste(collapse = "\n", readLines(file.path(test_path(), "test_webmocks", "data", "cran_package_archive.html"))),
headers = list(
"Content-Type" = "text/html; charset=utf-8",
"Content-Encoding" = "UTF-8"))
## CRAN logs downloads
# good
stub_request("get", uri_regex = ".+/downloads/daily/[^/]*/pkgcranremotegood[^/]*") %>%
to_return(
# build a json return payload of ~2k daily downloads over past year
body = mock_file(
path = tempfile(),
payload = build_downloads(pmax(round(rnorm(356, 2e3, 200)), 0))),
headers = list(
"Content-Type" = "application/json; charset=utf-8",
"Content-Encoding" = "UTF-8"))
# bad
stub_request("get", uri_regex = ".+/downloads/daily/[^/]*/pkgcranremotebad[^/]*") %>%
to_return(
# build a json return payload of ~10 daily downloads over < 1 month
body = mock_file(
path = tempfile(),
payload = build_downloads(pmax(round(rnorm(20, 10, 3)), 0))),
headers = list(
"Content-Type" = "application/json; charset=utf-8",
"Content-Encoding" = "UTF-8"))
# other
stub_request("get", uri_regex = ".+/downloads/daily/.*") %>%
to_return(
body = mock_file(path = tempfile(), payload = build_downloads()),
headers = list(
"Content-Type" = "application/json; charset=utf-8",
"Content-Encoding" = "UTF-8"))
# github bugreports via github's repo issues api
stub_request("get", uri_regex = "api\\.github\\.com/repos/[^/]+/[^/]+/issues") %>%
wi_th(query = list(state = "all", per_page = "30")) %>%
to_return(
body = paste(collapse = "\n", readLines(file.path(test_path(), "test_webmocks", "data", "github_repo_issues_api_response.json"))),
headers = list("Content-Type" = "application/json"))
================================================
FILE: tests/testthat/setup_test_packages.R
================================================
# create a series of reliably evaluated pkg reference objects that can be
# reused throughout testthat unit tests
# NOTE: score_error_zero is used for all scoring functions to suppress warnings
# and explicitly return zeros whenever errors are captured throughout the
# evaluation process. Errors are better tested in metric-specific unit tests.
# create a temporary library for installed test packages
options(repos = "fake-cran.fake-r-project.org")
templib <- tempfile("riskmetric_test_lib_")
oldLibs <- .libPaths()
dir.create(templib)
withr::with_libpaths(c(templib, oldLibs), {
pkg_path <- file.path(test_path(), "test_packages", "pkgsourcegood")
# build and install
pkg_archive <- pkgbuild::build(pkg_path, quiet = TRUE)
on.exit(file.remove(pkg_archive), add = TRUE)
install.packages(pkg_archive, type = "source", repos = NULL, quiet = TRUE)
# a representative "good" quality package from an installed package
pkg_ref_install_good <- pkg_install("pkgsourcegood")
assess_install_good <- pkg_assess(pkg_ref_install_good)
score_install_good <- pkg_score(
assess_install_good,
error_handler = score_error_zero
)
})
# a representative "good" quality package from source code
pkg_ref_source_good <- pkg_source(pkg_path)
assess_source_good <- pkg_assess(pkg_ref_source_good)
score_source_good <- pkg_score(
assess_source_good,
error_handler = score_error_zero
)
# a representative "bad" pkg_source package from source code
pkg_ref_source_bad <- pkg_source(file.path(
test_path(),
"test_packages",
"pkgsourcebad"
))
assess_source_bad <- pkg_assess(pkg_ref_source_bad)
score_source_bad <- pkg_score(
assess_source_bad,
error_handler = score_error_zero
)
# another representative "bad" pkg_source package from source code
pkg_ref_source_bad2 <- pkg_source(file.path(
test_path(),
"test_packages",
"pkgsourcebad2"
))
assess_source_bad2 <- pkg_assess(pkg_ref_source_bad2)
score_source_bad2 <- pkg_score(
assess_source_bad2,
error_handler = score_error_zero
)
# a representative package from an installed library
pkg_ref_stdlib_install <- pkg_install("utils")
assess_stdlib_install <- pkg_assess(pkg_ref_stdlib_install)
score_stdlib_install <- pkg_score(
assess_stdlib_install,
error_handler = score_error_zero
)
# a representative cohort of packages from an installed library
pkg_ref_stdlibs_install <- pkg_ref(c("utils", "tools"), source = "pkg_install")
assess_stdlibs_install <- pkg_assess(pkg_ref_stdlibs_install)
score_stdlibs_install <- pkg_score(
assess_stdlibs_install,
error_handler = score_error_zero
)
# a representative "good" quality package available on CRAN, but not installed
pkg_ref_cran_remote_good <- pkg_cran(
"pkgcranremotegood",
repos = "fake-cran.fake-r-project.org"
)
assess_cran_remote_good <- pkg_assess(pkg_ref_cran_remote_good)
score_cran_remote_good <- pkg_score(
assess_cran_remote_good,
error_handler = score_error_zero
)
# a representative "bad" quality package available on CRAN, but not installed
pkg_ref_cran_remote_bad <- pkg_cran(
"pkgcranremotebad",
repos = "fake-cran.fake-r-project.org"
)
assess_cran_remote_bad <- pkg_assess(pkg_ref_cran_remote_bad)
score_cran_remote_bad <- pkg_score(
assess_cran_remote_bad,
error_handler = score_error_zero
)
# a representative package without a discoverable reference
pkg_ref_missing <- pkg_missing("pkgmissing")
assess_pkg_missing <- pkg_assess(pkg_ref_missing)
score_pkg_missing <- pkg_score(
assess_pkg_missing,
error_handler = score_error_zero
)
withr::defer(unlink(templib, recursive = TRUE), teardown_env())
================================================
FILE: tests/testthat/teardown_mock_web_requests.R
================================================
options(riskmetric.tests = NULL)
stub_registry_clear()
httr_mock(FALSE)
rm(build_downloads)
================================================
FILE: tests/testthat/teardown_test_packages.R
================================================
rm(
pkg_ref_source_good,
assess_source_good,
pkg_ref_source_bad,
assess_source_bad,
pkg_ref_source_bad2,
assess_source_bad2,
score_source_bad2,
pkg_ref_stdlib_install,
assess_stdlib_install,
pkg_ref_stdlibs_install,
assess_stdlibs_install,
pkg_ref_cran_remote_good,
assess_cran_remote_good,
pkg_ref_cran_remote_bad,
assess_cran_remote_bad
)
================================================
FILE: tests/testthat/test_assess.R
================================================
test_that("pkg_assess on a single pkg_ref returns a vctrs_list_of with one element per assessment", {
expect_s3_class(assess_source_good, "vctrs_list_of")
expect_s3_class(assess_source_good, "list")
expect_length(assess_source_good, length(all_assessments()))
})
test_that("pkg_assess on list of pkg_refs returns a tibble with one col per assessment", {
expect_s3_class(assess_stdlibs_install, "tbl_df")
expect_s3_class(assess_stdlibs_install, "data.frame")
expect_length(assess_stdlibs_install, length(all_assessments()) + 3)
})
test_that("assess returns the correct classes", {
expect_s3_class(
assess_source_good$downloads_1yr,
c("pkg_metric_downloads_1yr", "pkg_metric", "numeric"))
expect_s3_class(
assess_source_good$license,
c("pkg_metric_license", "pkg_metric", "character"))
expect_s3_class(
assess_source_good$bugs_status,
c("pkg_metric_last_30_bugs_status", "pkg_metric", "logical"))
expect_s3_class(
assess_source_good$has_news,
c("pkg_metric_has_news", "pkg_metric", "integer"))
expect_s3_class(
assess_source_good$has_vignettes,
c("pkg_metric_has_vignettes", "pkg_metric", "integer"))
expect_s3_class(
assess_source_good$export_help,
c("pkg_metric_export_help", "pkg_metric", "logical"))
expect_s3_class(
assess_source_good$news_current,
c("pkg_metric_news_current", "pkg_metric", "logical"))
expect_s3_class(
assess_source_good$has_examples,
c("pkg_metric_has_examples", "pkg_metric", "integer"))
})
================================================
FILE: tests/testthat/test_assess_dependencies.R
================================================
test_that("assess_dependencies returns the correct number of dependencies", {
expect_s3_class(
assess_source_good$dependencies,
c("pkg_metric_dependencies", "pkg_metric", "data.frame"))
expect_equal(
nrow(assess_source_good$dependencies),
0)
})
================================================
FILE: tests/testthat/test_assess_export_help.R
================================================
# Commenting these out until this is implemented for sourced packages
test_that("assess_export_help returns expected result for source packages", {
expect_equal(unclass(unname(assess_source_good$export_help)), c(TRUE), ignore_attr = TRUE)
expect_equal(unclass(unname(assess_install_good$export_help)), c(TRUE), ignore_attr = TRUE)
expect_equal(unclass(unname(assess_source_bad$export_help)), c(FALSE, TRUE), ignore_attr = TRUE)
expect_true(assess_stdlibs_install$export_help[[1]][[1]])
expect_equal(score_install_good$export_help[[1]], 1, ignore_attr = TRUE)
expect_equal(score_source_bad$export_help[[1]], 0.5, ignore_attr = TRUE)
expect_equal(score_source_good$export_help[[1]], 1, ignore_attr = TRUE)
})
================================================
FILE: tests/testthat/test_assess_has_bug_reports_url.R
================================================
test_that("assess_has_bug_reports_url returns the correct url", {
expect_s3_class(
assess_source_good$has_bug_reports_url,
c("pkg_metric_has_bug_reports_url", "pkg_metric", "integer"))
expect_equal(as.numeric(assess_source_good$has_bug_reports_url), 1)
})
================================================
FILE: tests/testthat/test_assess_has_examples.R
================================================
test_that("assess_has_examples returns expected result for source packages", {
expect_equal(unclass(assess_source_good$has_examples[[1]]), TRUE)
expect_equal(unclass(assess_source_bad$has_examples[[1]]), TRUE)
})
test_that("check behavior of package that does not export any objects", {
expect_length(pkg_ref_source_bad2$examples, 0)
expect_length(assess_source_bad2$has_examples, 0)
expect_equal(unclass(score_source_bad2$has_examples[[1]]), NA)
})
================================================
FILE: tests/testthat/test_assess_has_news.R
================================================
test_that("assess_has_news returns expected result for source packages", {
# TODO: add other package types
expect_equal(unclass(assess_source_good$has_news[[1]]), 1)
expect_equal(unclass(assess_source_bad$has_news[[1]]), 0)
})
================================================
FILE: tests/testthat/test_assess_last_30_bugs_status.R
================================================
test_that("assess_last_30_bugs_status returns expected result for source package", {
# using mocked github api response
expect_s3_class(
assess_source_good$bugs_status,
c("pkg_metric_last_30_bugs_status", "pkg_metric", "logical"))
expect_equal(
as.vector(assess_source_good$bugs_status),
c(FALSE, TRUE, FALSE))
})
================================================
FILE: tests/testthat/test_assess_news_current.R
================================================
test_that("assess_news_current returns expected result for source packages", {
# TODO: Add other pkg_ref types
expect_true(assess_source_good$news_current[[1]])
expect_length(assess_source_bad$news_current, 0)
})
================================================
FILE: tests/testthat/test_metric_score_labels.R
================================================
test_that("scored assessments maintain labels which indicate what the score represents", {
pkg_scores_objs <- list(
# score_cran_remote_good,
# score_cran_remote_bad,
score_source_good
# score_source_bad,
# score_stdlib_install,
# score_stdlibs_install,
# score_pkg_missing
)
for (pkg_scores_i in pkg_scores_objs) {
expect_true({
scores_have_labels <- vapply(
pkg_scores_i,
function(i) !is.null(attr(i, "label")),
logical(1L))
all(scores_have_labels)
})
}
})
================================================
FILE: tests/testthat/test_metric_score_range.R
================================================
test_that("scored assessments are all between [0,1]", {
pkg_scores_objs <- list(
# score_cran_remote_good,
# score_cran_remote_bad,
score_source_good
# score_source_bad,
# score_stdlib_install,
# score_stdlibs_install,
# score_pkg_missing
)
for (pkg_scores_i in pkg_scores_objs) {
pkg_metric_idx <- which(sapply(pkg_scores_i, function(x) any(class(x) %in% "pkg_score")))
expect_true({
metrics_are_valid <- vapply(pkg_scores_i[pkg_metric_idx],
function(i) all(na.omit(i)<=1 & na.omit(i) >= 0),
logical(1L))
all(metrics_are_valid)
})
}
})
================================================
FILE: tests/testthat/test_packages/pkgsourcebad/DESCRIPTION
================================================
Package: pkgsourcebad
Title: A Test Package Used to Test Source Assessments
Version: 0.0.0.9000
Authors@R: "Eli Miller concordance function from package survivalMajor revision with added functionality. Any GLM family can be used now with glmnet, not just the built-in families. By passing a “family” object as the family argument (rather than a character string), one gets access to all families supported by glm. This development was programmed by our newest member of the glmnet team, Kenneth Tay.
Bug fixes
Intercept=FALSE with “Gaussian” is fixed. The dev.ratio comes out correctly now. The mortran code was changed directly in 4 places. look for “standard”. Thanks to Kenneth Tay.Bug fixes
confusion.glmnet was sometimes not returning a list because of apply collapsing structurecv.mrelnet and cv.multnet dropping dimensions inappropriatelystorePB to avoid segfault. Thanks Tomas Kalibera!assess.glmnet and cousins to be more helpful!lambda.interp to avoid edge cases (thanks David Keplinger)Minor fix to correct Depends in the DESCRIPTION to R (>= 3.6.0)
This is a major revision with much added functionality, listed roughly in order of importance. An additional vignette called relax is supplied to describe the usage.
relax argument added to glmnet. This causes the models in the path to be refit without regularization. The resulting object inherits from class glmnet, and has an additional component, itself a glmnet object, which is the relaxed fit.relax argument to cv.glmnet. This allows selection from a mixture of the relaxed fit and the regular fit. The mixture is governed by an argument gamma with a default of 5 values between 0 and 1.predict, coef and plot methods for relaxed and cv.relaxed objects.print method for relaxed object, and new print methods for cv.glmnet and cv.relaxed objects.trace.it=TRUE to glmnet and cv.glmnet. This can also be set for the session via glmnet.control.assess.glmnet, roc.glmnet and confusion.glmnet for displaying the performance of models.makeX for building the x matrix for input to glmnet. Main functionality is one-hot-encoding of factor variables, treatment of NA and creating sparse inputs.bigGlm for fitting the GLMs of glmnet unpenalized.In addition to these new features, some of the code in glmnet has been tidied up, especially related to CV.
coxnet.deviance to do with input pred, as well as saturated loglike (missing) and weightscoxgrad function for computing the gradientcv.glmnet, for cases when wierd things happeninst/mortraninst/mortran-Wall warningsnewoffset created problems all over - fixed theseexact=TRUE calls to coef and predict. See help file for more detailsy blows up elnet; error trap includedlambda.interp which was returning NaN under degenerate circumstances.Surv objectpredict and coef with exact=TRUE. The user is strongly encouraged to supply the original x and y values, as well as any other data such as weights that were used in the original fit.lognet when some weights are zero and x is sparsepredict.glmnet, predict.multnet and predict.coxnet, when s= argument is used with a vector of values. It was not doing the matrix multiply correctlyintercept optionglmnet.control for setting systems parameterscoxnetexact=TRUE option for prediction and coef functionsmgaussian family for multivariate responsegrouped option for multinomial familynewx and make dgCmatrix if sparselognet added a classnames component to the objectpredict.lognet(type="class") now returns a character vector/matrixpredict.glmnet : fixed bug with type="nonzero"glmnet: Now x can inherit from sparseMatrix rather than the very specific dgCMatrix, and this will trigger sparse mode for glmnetglmnet.Rd (lambda.min) : changed value to 0.01 if nobs < nvars, (lambda) added warnings to avoid single value, (lambda.min): renamed it lambda.min.ratioglmnet (lambda.min) : changed value to 0.01 if nobs < nvars (HessianExact) : changed the sense (it was wrong), (lambda.min): renamed it lambda.min.ratio. This allows it to be called lambda.min in a call thoughpredict.cv.glmnet (new function) : makes predictions directly from the saved glmnet object on the cv objectcoef.cv.glmnet (new function) : as abovepredict.cv.glmnet.Rd : help functions for the abovecv.glmnet : insert drop(y) to avoid 1 column matrices; now include a glmnet.fit object for later predictionsnonzeroCoef : added a special case for a single variable in x; it was dying on thisdeviance.glmnet : includeddeviance.glmnet.Rd : includedglmnet_1.4.Extremely efficient procedures for fitting the entire lasso or elastic-net regularization path for linear regression, logistic and multinomial regression models, Poisson regression, Cox model, multiple-response Gaussian, and the grouped multinomial regression. There are two new and important additions. The family argument can be a GLM family object, which opens the door to any programmed family. This comes with a modest computational cost, so when the built-in families suffice, they should be used instead. The other novelty is the relax option, which refits each of the active sets in the path unpenalized. The algorithm uses cyclical coordinate descent in a path-wise fashion, as described in the papers listed in the URL below.
| Version: | 4.0-2 |
| Depends: | R (≥ 3.6.0), Matrix (≥ 1.0-6) |
| Imports: | methods, utils, foreach, shape, survival |
| Suggests: | knitr, lars, testthat |
| Published: | 2020-06-16 |
| Author: | Jerome Friedman [aut], Trevor Hastie [aut, cre], Rob Tibshirani [aut], Balasubramanian Narasimhan [aut], Kenneth Tay [aut], Noah Simon [aut], Junyang Qian [ctb] |
| Maintainer: | Trevor Hastie <hastie at stanford.edu> |
| License: | GPL-2 |
| URL: | https://glmnet.stanford.edu, https://dx.doi.org/10.18637/jss.v033.i01, https://dx.doi.org/10.18637/jss.v039.i05 |
| NeedsCompilation: | yes |
| Citation: | glmnet citation info |
| Materials: | README NEWS |
| In views: | MachineLearning, Survival |
| CRAN checks: | glmnet results |
| Reference manual: | glmnet.pdf |
| Vignettes: |
Coxnet: Regularized Cox Regression An Introduction to glmnet Glm family Relaxed fits |
| Package source: | glmnet_4.0-2.tar.gz |
| Windows binaries: | r-devel: glmnet_4.0-2.zip, r-release: glmnet_4.0-2.zip, r-oldrel: glmnet_4.0-2.zip |
| macOS binaries: | r-release: glmnet_4.0-2.tgz, r-oldrel: glmnet_4.0-2.tgz |
| Old sources: | glmnet archive |
Please use the canonical form https://CRAN.R-project.org/package=glmnet to link to this page.
================================================ FILE: tests/testthat/test_webmocks/data/cran_package_archive.html ================================================Name Last modified SizeApache/2.4.39 (Unix) Server at cloud.r-project.org Port 80 ================================================ FILE: tests/testthat/test_webmocks/data/cran_package_checks.html ================================================
Parent Directory - glmnet_1.1-1.tar.gz 2008-06-27 06:35 60K glmnet_1.1-2.tar.gz 2008-12-23 08:02 60K glmnet_1.1-3.tar.gz 2009-01-24 10:12 61K glmnet_1.1-4.tar.gz 2009-12-18 16:36 64K glmnet_1.1-5.tar.gz 2010-01-31 10:11 64K glmnet_1.1.tar.gz 2008-06-02 07:00 57K glmnet_1.2.tar.gz 2010-04-04 15:43 83K glmnet_1.3.tar.gz 2010-04-25 07:26 83K glmnet_1.4.tar.gz 2010-06-16 15:35 84K glmnet_1.5.1.tar.gz 2010-11-19 07:33 463K glmnet_1.5.2.tar.gz 2011-02-07 09:50 463K glmnet_1.5.3.tar.gz 2011-03-01 00:04 463K glmnet_1.5.tar.gz 2010-11-04 20:16 463K glmnet_1.6.tar.gz 2011-04-24 06:08 510K glmnet_1.7.1.tar.gz 2011-09-23 11:45 510K glmnet_1.7.3.tar.gz 2012-02-19 09:12 510K glmnet_1.7.4.tar.gz 2012-04-27 06:02 470K glmnet_1.7.tar.gz 2011-06-15 18:50 511K glmnet_1.8-2.tar.gz 2012-10-02 06:20 507K glmnet_1.8-4.tar.gz 2012-12-27 22:11 507K glmnet_1.8-5.tar.gz 2013-01-04 08:21 507K glmnet_1.8.tar.gz 2012-07-03 17:50 484K glmnet_1.9-1.tar.gz 2013-02-10 19:17 514K glmnet_1.9-3.tar.gz 2013-03-02 07:14 519K glmnet_1.9-5.tar.gz 2013-08-04 00:09 524K glmnet_1.9-8.tar.gz 2014-05-24 20:49 525K glmnet_2.0-1.tar.gz 2015-04-08 09:12 1.8M glmnet_2.0-10.tar.gz 2017-05-06 06:23 3.7M glmnet_2.0-12.tar.gz 2017-09-13 17:35 3.7M glmnet_2.0-13.tar.gz 2017-09-22 05:43 3.7M glmnet_2.0-16.tar.gz 2018-04-02 12:06 3.7M glmnet_2.0-18.tar.gz 2019-05-20 05:10 3.7M glmnet_2.0-2.tar.gz 2015-04-11 22:56 1.8M glmnet_2.0-3.tar.gz 2016-02-23 06:18 1.8M glmnet_2.0-4.tar.gz 2016-03-13 10:29 1.8M glmnet_2.0-5.tar.gz 2016-03-17 13:00 1.8M glmnet_2.0-8.tar.gz 2017-04-30 07:02 3.3M glmnet_2.0-9.tar.gz 2017-05-02 20:39 3.7M glmnet_3.0-1.tar.gz 2019-11-15 06:50 1.5M glmnet_3.0-2.tar.gz 2019-12-11 17:00 1.5M glmnet_3.0.tar.gz 2019-11-09 10:20 1.5M glmnet_4.0.tar.gz 2020-05-14 17:30 2.0M
Last updated on 2021-07-06 20:48:30 CEST.
| Flavor | Version | Tinstall | Tcheck | Ttotal | Status | Flags |
|---|---|---|---|---|---|---|
| r-devel-linux-x86_64-debian-clang | 4.1-2 | OK | ||||
| r-devel-linux-x86_64-debian-gcc | 4.1-2 | 23.41 | 210.25 | 233.66 | OK | |
| r-devel-linux-x86_64-fedora-clang | 4.1-2 | 377.96 | OK | |||
| r-devel-linux-x86_64-fedora-gcc | 4.1-2 | 390.59 | OK | |||
| r-devel-windows-x86_64 | 4.1-2 | 40.00 | 274.00 | 314.00 | OK | |
| r-devel-windows-x86_64-gcc10-UCRT | 4.1-2 | OK | ||||
| r-patched-linux-x86_64 | 4.1-2 | 30.61 | 273.29 | 303.90 | OK | |
| r-patched-solaris-x86 | 4.1-2 | 272.90 | ERROR | |||
| r-release-linux-x86_64 | 4.1-2 | 31.34 | 275.73 | 307.07 | OK | |
| r-release-macos-arm64 | 4.1-2 | OK | ||||
| r-release-macos-x86_64 | 4.1-2 | OK | ||||
| r-release-windows-ix86+x86_64 | 4.1-2 | 47.00 | 426.00 | 473.00 | OK | |
| r-oldrel-macos-x86_64 | 4.1-2 | OK | ||||
| r-oldrel-windows-ix86+x86_64 | 4.1-2 | 68.00 | 367.00 | 435.00 | OK |
Version: 4.1-2
Check: examples
Result: ERROR
Running examples in ‘glmnet-Ex.R’ failed
The error most likely occurred in:
> ### Name: cox.path
> ### Title: Fit a Cox regression model with elastic net regularization for a
> ### path of lambda values
> ### Aliases: cox.path
>
> ### ** Examples
>
> set.seed(2)
> nobs <- 100; nvars <- 15
> xvec <- rnorm(nobs * nvars)
> xvec[sample.int(nobs * nvars, size = 0.4 * nobs * nvars)] <- 0
> x <- matrix(xvec, nrow = nobs)
> beta <- rnorm(nvars / 3)
> fx <- x[, seq(nvars / 3)] %*% beta / 3
> ty <- rexp(nobs, exp(fx))
> tcens <- rbinom(n = nobs, prob = 0.3, size = 1)
> jsurv <- survival::Surv(ty, tcens)
> fit1 <- glmnet:::cox.path(x, jsurv)
>
> # works with sparse x matrix
> x_sparse <- Matrix::Matrix(x, sparse = TRUE)
> fit2 <- glmnet:::cox.path(x_sparse, jsurv)
Error in elnet.fit(x, z, w, lambda, alpha, intercept = FALSE, thresh = thresh, :
NA/NaN/Inf in foreign function call (arg 23)
Calls: <Anonymous> -> cox.fit -> elnet.fit
Execution halted
Flavor: r-patched-solaris-x86
Version: 4.1-2
Check: re-building of vignette outputs
Result: WARN
Error(s) in re-building vignettes:
...
--- re-building ‘Coxnet.Rmd’ using rmarkdown
Warning in engine$weave(file, quiet = quiet, encoding = enc) :
Pandoc (>= 1.12.3) not available. Falling back to R Markdown v1.
(process:18845): Pango-WARNING **: failed to create cairo scaled font, expect ugly output. the offending font is 'Helvetica Medium 9'
(process:18845): Pango-WARNING **: font_face status is: <unknown error status>
(process:18845): Pango-WARNING **: scaled_font status is: invalid matrix (not invertible)
(process:18845): Pango-WARNING **: shaping failure, expect ugly output. shape-engine='BasicEngineFc', font='Helvetica Medium 9', text='m'
Quitting from lines 191-193 (Coxnet.Rmd)
Error: processing vignette 'Coxnet.Rmd' failed with diagnostics:
NA/NaN/Inf in foreign function call (arg 19)
--- failed re-building ‘Coxnet.Rmd’
--- re-building ‘glmnet.Rmd’ using rmarkdown
Warning in engine$weave(file, quiet = quiet, encoding = enc) :
Pandoc (>= 1.12.3) not available. Falling back to R Markdown v1.
Loaded lars 1.2
--- finished re-building ‘glmnet.Rmd’
--- re-building ‘glmnetFamily.Rmd’ using rmarkdown
Warning in engine$weave(file, quiet = quiet, encoding = enc) :
Pandoc (>= 1.12.3) not available. Falling back to R Markdown v1.
Loading required package: Matrix
Loaded glmnet 4.1-2
Quitting from lines 86-89 (glmnetFamily.Rmd)
Error: processing vignette 'glmnetFamily.Rmd' failed with diagnostics:
NA/NaN/Inf in foreign function call (arg 25)
--- failed re-building ‘glmnetFamily.Rmd’
--- re-building ‘relax.Rmd’ using rmarkdown
Warning in engine$weave(file, quiet = quiet, encoding = enc) :
Pandoc (>= 1.12.3) not available. Falling back to R Markdown v1.
--- finished re-building ‘relax.Rmd’
SUMMARY: processing the following files failed:
‘Coxnet.Rmd’ ‘glmnetFamily.Rmd’
Error: Vignette re-building failed.
Execution halted
Flavor: r-patched-solaris-x86