Skip to contents

Fetches every URL in the package, across DESCRIPTION, .Rd files and vignettes, and reports the ones that fail: 404s, other error statuses, and redirects that ought to point at their final target. This is what R CMD check --as-cran does, through the same base R machinery (tools::check_package_urls()), so you can see those findings without a full --as-cran pass and without depending on the urlchecker package.

Usage

lab_url_liveness(path = ".", verbose = TRUE)

Arguments

path

Character. Path to package directory

verbose

Logical. Print diagnostic messages

Value

checktor_check_result() with passed, issues, message.

Details

It runs by default when you are working at the console, since that is when a broken link is worth knowing about and a pause for the network is fine. It stays off in scripts, in continuous integration and under R CMD check, where a slow or unreachable network would make results depend on the machine rather than the package. Set the option either way to decide for yourself:

options(checktor.url_check = TRUE)   # always check
options(checktor.url_check = FALSE)  # never check

Without a network nothing can be fetched, so the check is reported as skipped rather than as passing. For the offline half, which flags http:// links and URL shorteners without leaving the room, see lab_urls().

Source

The CRAN incoming check run by R CMD check --as-cran fetches URLs and NOTEs 404s and redirects. See vignette("check-sources", package = "checktor") for how every check maps to its source.

Examples

# Needs a network: it asks every URL the package lists whether it answers,
# so it is not run here. The scenario lists one page that exists and one that
# does not, and the missing one is reported with its 404. Outside an
# interactive session the check is skipped unless
# options(checktor.url_check = TRUE) turns it on.
if (FALSE) { # \dontrun{
pkg <- example_diagnose_scenario("general_examples/url_liveness_bad.txt",
                                 show_content = FALSE)
lab_url_liveness(pkg, verbose = FALSE)$issues
unlink(pkg, recursive = TRUE)
} # }