开发者

What is an easy way to calculate the CRAP metric in my Javascript build process? [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 9 years ago.

I'm a fan of the CRAP metric, and use it to monitor code quality for开发者_Python百科 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?


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).


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜