| Title: | Cyclomatic Complexity of R Code |
|---|---|
| Description: | Cyclomatic complexity is a software metric (measurement), used to indicate the complexity of a program. It is a quantitative measure of the number of linearly independent paths through a program's source code. It was developed by Thomas J. McCabe, Sr. in 1976. |
| Authors: | Gabor Csardi [aut, cre] |
| Maintainer: | Gabor Csardi <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 1.1.2.9000 |
| Built: | 2026-05-10 08:46:08 UTC |
| Source: | https://github.com/gaborcsardi/cyclocomp |
Cyclomatic complexity is a software metric (measurement), used to indicate the complexity of a program. It is a quantitative measure of the number of linearly independent paths through a program's source code. It was developed by Thomas J. McCabe, Sr. in 1976.
Calculate the cyclomatic complexity of an R function or expression.
cyclocomp(expr) cyclocomp_q(expr)cyclocomp(expr) cyclocomp_q(expr)
expr |
An R function or expression. |
Integer scalar, the cyclomatic complexity of the expression.
Useful links:
Report bugs at https://github.com/gaborcsardi/cyclocomp/issues
Other cyclomatic complexity:
cyclocomp_package(),
cyclocomp_package_dir()
## Supply a function cyclocomp( function(arg) { calulate(this); and(that) } ) cyclocomp(ls) cyclocomp(cyclocomp) ## Or a quoted expression cyclocomp(quote( if (condition) "foo" else "bar" )) ## cyclocomp_q quotes the expression for you cyclocomp_q(while (condition) { loop }) ## Complexity of individual control flow constructs cyclocomp(quote({ if (condition) this })) cyclocomp(quote({ if (condition) this else that })) cyclocomp(quote({ for (var in seq) expr })) cyclocomp(quote({ while (cond) expr })) cyclocomp(quote({ repeat expr })) cyclocomp(quote({ for (var in seq) { this break that } })) cyclocomp(quote({ for (var in seq) { this next that } }))## Supply a function cyclocomp( function(arg) { calulate(this); and(that) } ) cyclocomp(ls) cyclocomp(cyclocomp) ## Or a quoted expression cyclocomp(quote( if (condition) "foo" else "bar" )) ## cyclocomp_q quotes the expression for you cyclocomp_q(while (condition) { loop }) ## Complexity of individual control flow constructs cyclocomp(quote({ if (condition) this })) cyclocomp(quote({ if (condition) this else that })) cyclocomp(quote({ for (var in seq) expr })) cyclocomp(quote({ while (cond) expr })) cyclocomp(quote({ repeat expr })) cyclocomp(quote({ for (var in seq) { this break that } })) cyclocomp(quote({ for (var in seq) { this next that } }))
Note that the package must be installed.
cyclocomp_package(package)cyclocomp_package(package)
package |
Package name, character scalar. |
Data frame with two columns: name and cyclocomp.
Other cyclomatic complexity:
cyclocomp(),
cyclocomp_package_dir()
## They might take a while to run ## Not run: cyclocomp_package("grDevices") cyclocomp_package("methods") ## End(Not run)## They might take a while to run ## Not run: cyclocomp_package("grDevices") cyclocomp_package("methods") ## End(Not run)
Automatically builds the package and installs it to a temporary directory.
cyclocomp_package_dir(path = ".", quiet = TRUE)cyclocomp_package_dir(path = ".", quiet = TRUE)
path |
Path to the root directory of the R package. |
quiet |
If 'FALSE', display package build information. |
Data frame with two columns: name and cyclocomp.
Other cyclomatic complexity:
cyclocomp(),
cyclocomp_package()