R/assess_has_news.R

Defines functions metric_score.pkg_metric_has_news assess_has_news.pkg_ref assess_has_news

Documented in assess_has_news metric_score.pkg_metric_has_news

#' Assess a package for the presence of a NEWS file
#'
#' @eval roxygen_assess_family(
#'   "has_news",
#'   "an integer value indicating the number of discovered NEWS files")
#'
#' @export
assess_has_news <- function(x, ...) {
  UseMethod("assess_has_news")
}

# assign a friendly name for assess column
attributes(assess_has_news)$column_name <- "has_news"
attributes(assess_has_news)$label <- "number of discovered NEWS files"



#' @export
assess_has_news.pkg_ref <- function(x, ...) {
  pkg_metric(class = "pkg_metric_has_news", {
    length(x$news)
  })
}



#' Score a package for the presence of a NEWS file
#'
#' Coerce the number of news files to binary indication of valid NEWS files
#'
#' @eval roxygen_score_family("has_news")
#' @return \code{1} if any NEWS files are found, otherwise \code{0}
#'
#' @export
metric_score.pkg_metric_has_news <- function(x, ...) {
  as.numeric(x > 0)
}

attributes(metric_score.pkg_metric_has_news)$label <-
  "A binary indicator of whether a package has an associated NEWS file."

Try the riskmetric package in your browser

Any scripts or data that you put into this service are public.

riskmetric documentation built on Sept. 1, 2023, 1:06 a.m.