Learn R Programming

packager (version 1.15.2)

check_cyclomatic_complexity: 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)

Value

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

Arguments

path

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

max_complexity

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

See Also

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

Examples

Run this code
if (FALSE) {
# 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)
}

Run the code above in your browser using DataLab