SourceMonitor 中用于计算复杂性的参数是什么?

发布于 2024-09-04 05:02:38 字数 186 浏览 14 评论 0原文

我最近开始使用 SourceMonitor 来检查我(和其他人)的代码。 虽然我了解该工具判断的其他参数,但我不知道它是如何计算代码的复杂度的。例如,它考虑读取复杂度数字的所有参数是什么?

I recently started using SourceMonitor to review my (and others) code.
Though I understand other parameters judged by the tool, I don't know how does it calculates the complexity of the code. As in, what all parameters does it considers to read to a complexity number?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

夜光 2024-09-11 05:02:38

发现它在
帮助->帮助主题 ->语言指标解释-> C#->最大方法复杂度 -> (有一个hyperling)复杂性值。

源监视器复杂度值 http://tinypic.com/r/10yi0kp/6

Found it in
Help -> Help Topics -> Explanation of language Metrics -> C# -> Max Method Complexity -> (There is a hyperling) Complexity Value.

Source Monitor Complexity Value http://tinypic.com/r/10yi0kp/6

辞取 2024-09-11 05:02:38

如果没有他们的说明,很难知道,但最常见的衡量标准之一是圈复杂度 - 通过代码的路由数量的度量。一个简单的自上而下的过程方法的复杂度为 1,所有循环/分支/捕获等都会增加这一点。这个想法是,如果这个值增长得太高,那么你的方法就做得太多了,应该重构为一些更小、更有针对性的方法。


编辑; 从这里

已添加 C# 解析器。大多数指标与 C++ 和 Java 类似。主要区别在于如何确定“最大”方法。对于 C# 来说,不是识别语句最多的方法,而是为每个文件找到最复杂的方法。 复杂度测量类似于循环复杂度 - 对代码中可能路径的计数。

(强调我的)所以听起来他们有一个稍微修改过的常规 CC 变体。只有他们才能告诉你他们做了什么不同的事情;p

It is hard to know without them stating it, but one of the most common measures is cyclomatic complexity - a measure of the number of routes through code. A simple top-to-bottom procedural method has complexity 1, with all loops / branches / catches etc adding to this. The idea is that if this grows too high, your method is doing too much and should be refactored into a few smaller, more targetted methods.


Edit; from here:

A parser for C# has been added. Most of the metrics are similar to C++ and Java. The primary difference is how the "biggest" method is determined. Instead of identifying the method with the most statements, for C# the most complex method is found for each file. The complexity measurement is similar to Cyclomatic Complexity - a count of the possible pathways through the code.

(emphasis mine) so it sounds like they have a slightly modified variant of regular CC. Only they can tell you what they did different ;p

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文