コード例 #1
0
        /// <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);
        }
コード例 #2
0
 internal MIMetricCheck(SpecificMetricThresholds thresholds)
     : base(thresholds.MaintainabilityIndexThresholds)
 {
 }
コード例 #3
0
 internal DOIMetricCheck(SpecificMetricThresholds thresholds)
     : base(thresholds.DepthOfInheritanceThresholds)
 {
 }
コード例 #4
0
 internal LOCMetricCheck(SpecificMetricThresholds thresholds)
     : base(thresholds.LinesOfCodeThresholds)
 {
 }
コード例 #5
0
 internal COMetricCheck(SpecificMetricThresholds thresholds)
     : base(thresholds.CouplingThresholds)
 {
 }
コード例 #6
0
 internal CCMetricCheck(SpecificMetricThresholds thresholds)
     : base(thresholds.CyclomaticComplexityThresholds)
 {
 }