循环复杂度衡量一个功能可以使用多少个分支。是否有用于计算R功能的现有功能/工具?如果不是这样,建议就最好的方式写出建议。
Cyclomatic complexity measures how many possible branches can be taken through a function. Is there an existing function/tool to calculate it for R functions? If not, suggestions are appreciated for the best way to write one.
一个便宜的开始是算出所有的出现, ifelse 或 switch 。但是,要获得真实的答案,您需要了解分支的开始和结束时间,这要困难得多。
A cheap start towards this would be to count up all the occurences of if, ifelse or switch within your function. To get a real answer though, you need to understand when branches start and end, which is much harder. Maybe some R parsing tools would get us started?
推荐答案我还发现了一个名为cyclocomp的新程序包(2016年发布)。看看吧!
Also, I just found a new package called cyclocomp (released 2016). Check it out!
更多推荐
如何计算R函数的圈复杂度?
发布评论