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
// <Name>C.R.A.P method code metric</Name> | |
// 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) | |
warnif count > 0 | |
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 | |
orderby CRAP descending, m.NbLinesOfCode descending | |
select new { m, CRAP, CC, uncoveredPercentage = uncov*100, m.NbLinesOfCode } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment