check_cyclomatic_complexity: Check Cyclomatic Complexity

View source: R/checks.R

check_cyclomatic_complexityR Documentation

Check ⁠Cyclomatic Complexity⁠

Description

Run cyclocomp_package_dir on the package throwing an error when the maximum complexity is exceeded.

Usage

check_cyclomatic_complexity(path = ".", max_complexity = 10)

Arguments

path

Path to the package directory (see devtools::as.package).

max_complexity

The maximum ⁠cyclomatic complexity⁠ (which must not be exceeded).

Value

Invisibly TRUE if maximum ⁠cyclomatic complexity⁠ is not exceeded, throws an error otherwise.

See Also

Other maintenance functions: check_archive(), check_codetags(), check_news(), check_usage(), get_check_status()

Examples

## Not run: 
# download and untar sources of some archived package
package  <- "excerptr"
root <- paste0("http://cran.r-project.org/src/contrib/Archive/", package)
version <- "1.0.0"
tarball <- paste0(paste(package, version, sep = "_"), ".tar.gz")
remote_tarball <- paste(root, tarball, sep = "/")
local_tarball <- file.path(tempdir(), tarball)
utils::download.file(remote_tarball, local_tarball)
utils::untar(local_tarball, exdir = tempdir())
res <- tryCatch(check_cyclomatic_complexity(path = file.path(tempdir(),
                                                             package)),
                error = identity)
print(res)

## End(Not run)

packager documentation built on Aug. 16, 2023, 5:08 p.m.