/// <summary> /// Build a suitable collection of valid Metrics based on the selected MetricSet. /// <remarks>An empty MetricSet will result in all metrics being added, with the exception of Project /// level metrics which are always omitted.</remarks> /// </summary> /// <param name="metricSet">Selected MetricSet, acting as a filter on the columns to be displayed.</param> /// <returns></returns> protected MetricCollection ChooseMetrics(MetricSet metricSet) { MetricCollection rval = new MetricCollection(); foreach (Metric m in KrakatauSettings.Settings.Metrics) { bool include = false; if (m.Level == MetricLevel.Project) { include = false; } else if (metricSet == null) { include = true; } else { include = metricSet.Contains(m); } if (include) { rval.Add(m); } } return(rval); }
// Adjust lists to include empty methods in diff|base for methods that appear only in base|diff. // Also adjust delta to take these methods into account. public void Reconcile() { List <MethodDelta> reconciles = new List <MethodDelta>(); reconciledBaseMetrics = new MetricCollection(); reconciledDiffMetrics = new MetricCollection(); foreach (MethodInfo m in methodsOnlyInBase) { reconciles.Add(new MethodDelta { name = m.name, baseMetrics = new MetricCollection(m.Metrics), diffMetrics = new MetricCollection(), baseOffsets = m.functionOffsets, diffOffsets = null }); baseMetrics.Add(m.Metrics); reconciledBaseMetrics.Add(m.Metrics); reconciledCountBase++; } foreach (MethodInfo m in methodsOnlyInDiff) { reconciles.Add(new MethodDelta { name = m.name, baseMetrics = new MetricCollection(), diffMetrics = new MetricCollection(m.Metrics), baseOffsets = null, diffOffsets = m.functionOffsets }); diffMetrics.Add(m.Metrics); reconciledDiffMetrics.Add(m.Metrics); reconciledCountDiff++; } methodDeltaList = methodDeltaList.Concat(reconciles); deltaMetrics.Sub(reconciledBaseMetrics); deltaMetrics.Add(reconciledDiffMetrics); }
public void MetricCollection_Add() { var col = new MetricCollection(); col.Add(new Metric(MetricType.EventLog, "m", true)); }
protected void PopulateMetrics() { Metrics = new MetricCollection(); // Add the General metrics Metrics.Add(new Metric(100, MetricType.General, "LOC")); Metrics.Add(new Metric(101, MetricType.General, "SLOC")); Metrics.Add(new Metric(102, MetricType.General, "SLOC_NAT")); Metrics.Add(new Metric(103, MetricType.General, "SLOC_TAG")); Metrics.Add(new Metric(104, MetricType.General, "SLOC_HTM")); Metrics.Add(new Metric(105, MetricType.General, "SLOC_SCR")); Metrics.Add(new Metric(106, MetricType.General, "PLOC")); Metrics.Add(new Metric(107, MetricType.General, "LLOC")); Metrics.Add(new Metric(108, MetricType.General, "N1")); Metrics.Add(new Metric(109, MetricType.General, "N2")); Metrics.Add(new Metric(110, MetricType.General, "N1S")); Metrics.Add(new Metric(111, MetricType.General, "N2S")); Metrics.Add(new Metric(112, MetricType.General, "N")); Metrics.Add(new Metric(113, MetricType.General, "NS")); Metrics.Add(new Metric(114, MetricType.General, "V")); Metrics.Add(new Metric(115, MetricType.General, "D")); Metrics.Add(new Metric(116, MetricType.General, "E")); Metrics.Add(new Metric(117, MetricType.General, "B")); Metrics.Add(new Metric(118, MetricType.General, "J_COM")); Metrics.Add(new Metric(119, MetricType.General, "C_COM")); Metrics.Add(new Metric(120, MetricType.General, "CPP_COM")); Metrics.Add(new Metric(121, MetricType.General, "COM_LOC")); Metrics.Add(new Metric(122, MetricType.General, "BYTES")); Metrics.Add(new Metric(123, MetricType.General, "NFILE", MetricLevel.Project)); // Add the Changed metrics Metrics.Add(new Metric(124, MetricType.Changed, "CHG_SLOC")); Metrics.Add(new Metric(125, MetricType.Changed, "DEL_SLOC")); Metrics.Add(new Metric(126, MetricType.Changed, "ADD_SLOC")); Metrics.Add(new Metric(127, MetricType.Changed, "CRN_SLOC")); Metrics.Add(new Metric(128, MetricType.Changed, "CHG_LLOC")); Metrics.Add(new Metric(129, MetricType.Changed, "DEL_LLOC")); Metrics.Add(new Metric(130, MetricType.Changed, "ADD_LLOC")); Metrics.Add(new Metric(131, MetricType.Changed, "CRN_LLOC")); Metrics.Add(new Metric(132, MetricType.Changed, "CHG_FILE", MetricLevel.Project)); Metrics.Add(new Metric(133, MetricType.Changed, "DEL_FILE", MetricLevel.Project)); Metrics.Add(new Metric(134, MetricType.Changed, "ADD_FILE", MetricLevel.Project)); Metrics.Add(new Metric(135, MetricType.Changed, "CRN_FILE", MetricLevel.Project)); }