priv-kweihmann/multimetric

Maintainability SEI Calculation uses log2 instead of ln

Closed this issue · 4 comments

Branch 2.x

try:
res = 171.0 - (5.2 * math.log2(metrics["halstead_volume"]))
res -= 0.23 * metrics["cyclomatic_complexity"]
res -= 16.2 * math.log2(metrics["loc"])
res += 50.0 * abs(math.sin(math.sqrt(2.4 * metrics["comment_ratio"])))
return res

V1.3
MI_METHOD = {
"sei": '171.0 \
- (5.2 * math.log2(metrics["halstead_volume"])) \
- (0.23 * metrics["cyclomatic_complexity"]) \
- (16.2 * math.log2(metrics["loc"])) \
+ (50.0 * math.sin(math.sqrt(2.4 * metrics["comment_ratio"])))',
"classic": '171.0 \
- (5.2 * math.log(metrics["halstead_volume"])) \
- (0.23 * metrics["cyclomatic_complexity"]) \
- (16.2 * math.log(metrics["loc"]))',
"microsoft": 'max(0, \
171.0 \
- (5.2 * math.log(metrics["halstead_volume"])) \
- (0.23 * metrics["cyclomatic_complexity"]), \
- (16.2 * math.log(metrics["loc"]) * 100.0 / 171.0))'
}

Hey i found a issue that the SEI maintainiblity calculation uses log base 2 instead of ln like discribed in the reference given https://insights.sei.cmu.edu/documents/1625/1997_002_001_16523.pdf page 232

Appart from that the documentation of classic method does not match the calculation

171 - 5.2 x ln(aveVol) - 0.23 x aveV(g’) - 16.2 x ln(aveLoC) + (50 x sin(sqrt(2.46 x perCM)))

Patches welcome!!!!

@priv-kweihmann please see PullRequest #82

PR merged, I guess we can close the ticket now

Thanks. Currently working on a additional PR about the radon calculation. And as I tried to implement it noticed that Comment percent is not 0-1 which is expected. This might be problematic for sei too might do changes to sei too will try to verify calculations externally