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.
Installation
devtools::install_github("MangoTheCat/cyclocomp")
Usage
library(cyclocomp)
cyclocomp takes quoted R expressions or function objects,
and returns a single integer, the cyclomatic complexity of the
expression or function.
cyclocomp(quote( if (condition) "foo" else "bar" ))
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.
Installation
Usage
cyclocomptakes quoted R expressions or function objects, and returns a single integer, the cyclomatic complexity of the expression or function.Some more examples for the R control structures. A simple
iffirst:An
ifwith anelsebranch:Loops:
breakandnextstatements add to the complexity:Multiple (explicit or implicit)
returncalls also add to the complexity:License
MIT © Mango Solutions