/// <summary> /// Analyzes the resulting metrics file and compares the metrics against the threshold values /// </summary> /// <param name="parent">The parent node in the build log</param> /// <param name="metrics">List of metric values</param> /// <param name="thresholds">Thresholds for errors and warnings </param> /// <param name="fullyQualifiedName">FQN for the method/type under test</param> /// <param name="currentName">Name of current method/type </param> /// <returns>Number if violations</returns> private int ProcessMetrics(IBuildInformationNode parent, IEnumerable <Metric> metrics, SpecificMetricThresholds thresholds, string fullyQualifiedName, string currentName) { var thecomplainlist = new List <string>(); foreach (var metric in metrics.Where(metric => metric != null && !string.IsNullOrEmpty(metric.Value))) { switch (metric.Name) { case MaintainabilityIndex: this.CheckLimits(metric, thresholds.MIMetricChecker, fullyQualifiedName, thecomplainlist); break; case CyclomaticComplexity: this.CheckLimits(metric, thresholds.CCMetricChecker, fullyQualifiedName, thecomplainlist); break; case ClassCoupling: this.CheckLimits(metric, thresholds.COMetricChecker, fullyQualifiedName, thecomplainlist); break; case DepthOfInheritance: this.CheckLimits(metric, thresholds.DOIMetricChecker, fullyQualifiedName, thecomplainlist); break; case LinesOfCode: this.CheckLimits(metric, thresholds.LOCMetricChecker, fullyQualifiedName, thecomplainlist); break; default: throw new UnknownMetricNameException(metric.Name); } } if (this.logCodeMetrics && parent != null && thecomplainlist.Count > 0) { var result = "Metrics for " + currentName + @"\n"; thecomplainlist.ForEach(s => result += s + @"\n"); BaseCodeActivity.AddTextNode(result, parent); } return(thecomplainlist.Count); }
internal MIMetricCheck(SpecificMetricThresholds thresholds) : base(thresholds.MaintainabilityIndexThresholds) { }
internal DOIMetricCheck(SpecificMetricThresholds thresholds) : base(thresholds.DepthOfInheritanceThresholds) { }
internal LOCMetricCheck(SpecificMetricThresholds thresholds) : base(thresholds.LinesOfCodeThresholds) { }
internal COMetricCheck(SpecificMetricThresholds thresholds) : base(thresholds.CouplingThresholds) { }
internal CCMetricCheck(SpecificMetricThresholds thresholds) : base(thresholds.CyclomaticComplexityThresholds) { }