如何计算R函数的圈复杂度? [英] How do you calculate cyclomatic complexity for R functions?

查看:138
本文介绍了如何计算R函数的圈复杂度?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

循环复杂度衡量一个功能可以使用多少个分支。是否有用于计算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函数的圈复杂度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆