答案 0 :(得分:0)
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;
因此,您需要calculate the cyclomatic complexity和calculate the test code coverage(或here)。
答案 1 :(得分:0)
jshint计算圈复杂度,请参阅http://www.jshint.com/docs/参数maxcomplexity。 我不知道,你如何检索结果,但你可能会查看jshint源代码。 希望有所帮助