如何计算R函数的圈复杂度?

编程入门 行业动态 更新时间:2024-10-14 10:38:42
本文介绍了如何计算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函数的圈复杂度?

本文发布于:2023-11-30 17:26:32,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1650889.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:复杂度   函数

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!