public static CrapResult Build(IEnumerable<Crap> crap, Func<int, IEnumerable<Crap>> aboveThreshold, int crapThreshold) { var crapResult = new CrapResult(); GetSummary(crapResult, aboveThreshold, crapThreshold, crap); List<CrapMethod> methods = GetMethods(crap); crapResult.Methods = methods; return crapResult; }
private static void GetSummary(CrapResult crapResult, Func<int, IEnumerable<Crap>> aboveThreshold, int crapThreshold, IEnumerable<Crap> crap) { var crappyMethods = aboveThreshold(crapThreshold); crapResult.Summary = new Summary { CrapLoad = Math.Round(crappyMethods.Sum(c => c.CrapLoad()), 1), TotalMethods = crap.Count(), CrappyMethods = crappyMethods.Count(), CrapThreshold = crapThreshold }; }