Diagnose Reference Formatting in DESCRIPTION
Source:R/diagnostics-description-references.R
lab_references.RdFlags the links in the Description that CRAN's incoming check NOTEs,
applying its own rules to the same wrapped lines R reads:
Arguments
- path
Character. Path to the package directory. Default:
".".- verbose
Logical. Print diagnostic output. Default:
TRUE.- desc
Optional pre-parsed
DESCRIPTION, as returned bybase::read.dcf(). Defaults to reading it frompath.
Value
checktor_check_result() with passed, issues, message.
Details
a URL not enclosed in angle brackets, which should read
<https://...>;a DOI not written as
<doi:prefix/suffix>, such as ahttps://doi.org/link, a baredoi:,<doiwith no colon, or<10.xxxx/...>;a publisher link that embeds a DOI, such as
<https://onlinelibrary.wiley.com/doi/10.1002/...>, reported only when no DOI is malformed, as R does;an arXiv id or link, such as
<arXiv:1509.03700>or<https://arxiv.org/abs/...>, which should be the e-print's arXiv DOI,<doi:10.48550/arXiv.1509.03700>.
It also flags a reference with no closing >, which CRAN's page does not
render as a link. Each rule is one finding, quoting every reference that
breaks it. A space after the colon, as in <doi: 10.1000/xyz>, is left
alone: R does not NOTE it and CRAN's page links it all the same.
Source
The CRAN incoming check
run by R CMD check --as-cran NOTEs each of the four forms, with "Please
enclose URLs in angle brackets (<...>).", "Please write DOIs as
doi:prefix/suffix.", "Please use permanent DOI markup for linking to
publications as in doi:prefix/suffix." and "Please refer to arXiv e-prints
via their arXiv DOI doi:10.48550/arXiv.YYMM.NNNNN.". The
submission checklist
says "arXiv preprints should be referred to via their arXiv DOI", and the
Cookbook's References
recipe asks for "angle brackets for auto-linking". devtools::check() turns the incoming check off, so these
usually surface first on win-builder or at CRAN. See
vignette("check-sources", package = "checktor") for how every check maps to
its source.
See also
checktor(), which runs this and every other check.
Examples
pkg <- example_diagnose_scenario("description_examples/references_bad.txt",
show_content = FALSE)
lab_references(pkg, verbose = FALSE)$issues
#> [1] "URL not enclosed in angle brackets (<...>): https://colorcet.com"
#> [2] "DOI not written as <doi:prefix/suffix>: doi:10.1000/xyz123"
#> [3] "arXiv reference, which CRAN asks to see as its arXiv DOI: <arXiv:1509.03700> (write <doi:10.48550/arXiv.1509.03700>)"
unlink(pkg, recursive = TRUE)