在 Javascript 构建过程中计算 CRAP 指标的简单方法是什么?

发布于 2024-10-07 04:05:31 字数 335 浏览 0 评论 0原文

我是 CRAP 指标的粉丝,并用它来监控我的 C#Java 项目。

我想为我不断增长的 Javascript 代码库做同样的事情。

是否有现有流程可以轻松集成到我的 Javascript 构建流程中?

I'm a fan of the CRAP metric, and use it to monitor code quality for my C# and Java projects.

I'd like to do the same for my growing Javascript codebase.

Is there an existing process that makes this easy to integrate into my Javascript build process?

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

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

发布评论

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

评论(2

风追烟花雨 2024-10-14 04:05:31

CRAP 公式为:

var complexity = ...; //cyclomatic complexity of a method
var coverage   = ...; //test code coverage for the method
var crap = Math.pow(complexity,2) * Math.pow(1 – coverage/100,3) + complexity;

因此,您需要 计算圈复杂度计算测试代码覆盖率(或此处)。

The CRAP formula is:

var complexity = ...; //cyclomatic complexity of a method
var coverage   = ...; //test code coverage for the method
var crap = Math.pow(complexity,2) * Math.pow(1 – coverage/100,3) + complexity;

So, you need to calculate the cyclomatic complexity and calculate the test code coverage (or here).

世界如花海般美丽 2024-10-14 04:05:31

jshint 计算圈复杂度,请参见 http://www.jshint.com/docs/ 参数 maxcomplexity。
我不知道如何检索结果,但您可以查看 jshint 源。
希望有帮助

jshint calculates the cyclomatic complexity, see http://www.jshint.com/docs/ parameter maxcomplexity.
I don't know, how you can retrieve the results, but you might look into the jshint sources.
Hope that helps

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