Created
September 26, 2013 09:38
-
-
Save anonymous/6711976 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// <TrendMetric Name="Max C.R.A.P Score" /> | |
// Change Risk Analyzer and Predictor (i.e. CRAP) code metric | |
// This code metric helps in pinpointing overly complex and untested code. | |
// Reference: http://www.artima.com/weblogs/viewpost.jsp?thread=215899 | |
// Formula: CRAP(m) = comp(m)^2 * (1 - cov(m)/100)^3 + comp(m) | |
(from m in JustMyCode.Methods | |
// Don't match too short methods | |
where m.NbLinesOfCode > 10 | |
let CC = m.CyclomaticComplexity | |
let uncov = (100 - m.PercentageCoverage) / 100f | |
let CRAP = (CC * CC * uncov * uncov * uncov) + CC | |
where CRAP != null && CRAP > 30 select CRAP) | |
.Max(CRAP => CRAP) | |
// To list methods with highest C.R.A.P scores, please refer to the default rule: | |
// Test and Code Coverage > C.R.A.P method code metric |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment