public override TableDefinition Content(ReportData reportData, Dictionary <string, string> options) { TableDefinition back = new TableDefinition(); bool hasPreviousSnapshot = (null != reportData.PreviousSnapshot); if (reportData.CurrentSnapshot == null) { return(back); } #region Selected Snapshot var selectedLowVal = CastComplexityUtility.GetCostComplexityGrade(reportData.CurrentSnapshot, Constants.QualityDistribution.CostComplexityDistribution.GetHashCode(), Constants.CostComplexity.CostComplexityArtifacts_Low.GetHashCode()); var selectedAveVal = CastComplexityUtility.GetCostComplexityGrade(reportData.CurrentSnapshot, Constants.QualityDistribution.CostComplexityDistribution.GetHashCode(), Constants.CostComplexity.CostComplexityArtifacts_Average.GetHashCode()); var selectedHigVal = CastComplexityUtility.GetCostComplexityGrade(reportData.CurrentSnapshot, Constants.QualityDistribution.CostComplexityDistribution.GetHashCode(), Constants.CostComplexity.CostComplexityArtifacts_High.GetHashCode()); var selectedVhiVal = CastComplexityUtility.GetCostComplexityGrade(reportData.CurrentSnapshot, Constants.QualityDistribution.CostComplexityDistribution.GetHashCode(), Constants.CostComplexity.CostComplexityArtifacts_VeryHigh.GetHashCode()); double?selectedTotal = 0; if (selectedLowVal.HasValue) { selectedTotal += selectedLowVal; } if (selectedAveVal.HasValue) { selectedTotal += selectedAveVal; } if (selectedHigVal.HasValue) { selectedTotal += selectedHigVal; } if (selectedVhiVal.HasValue) { selectedTotal += selectedVhiVal; } #endregion Selected Snapshot #region Previous Snapshot double?previousLowVal = null; double?previousAveVal = null; double?previousHigVal = null; double?previousVhiVal = null; if (hasPreviousSnapshot) { previousLowVal = CastComplexityUtility.GetCostComplexityGrade(reportData.PreviousSnapshot, Constants.QualityDistribution.CostComplexityDistribution.GetHashCode(), Constants.CostComplexity.CostComplexityArtifacts_Low.GetHashCode()); previousAveVal = CastComplexityUtility.GetCostComplexityGrade(reportData.PreviousSnapshot, Constants.QualityDistribution.CostComplexityDistribution.GetHashCode(), Constants.CostComplexity.CostComplexityArtifacts_Average.GetHashCode()); previousHigVal = CastComplexityUtility.GetCostComplexityGrade(reportData.PreviousSnapshot, Constants.QualityDistribution.CostComplexityDistribution.GetHashCode(), Constants.CostComplexity.CostComplexityArtifacts_High.GetHashCode()); previousVhiVal = CastComplexityUtility.GetCostComplexityGrade(reportData.PreviousSnapshot, Constants.QualityDistribution.CostComplexityDistribution.GetHashCode(), Constants.CostComplexity.CostComplexityArtifacts_VeryHigh.GetHashCode()); } #endregion Previous Snapshot #region Data List <string> rowData = new List <string>(); rowData.AddRange(new[] { Labels.Complexity, Labels.Current, Labels.Previous, Labels.Evol, Labels.EvolPercent, Labels.TotalPercent }); const string noData = Constants.No_Value; rowData.AddRange(new[] { Labels.ComplexityLow , selectedLowVal?.ToString("N0") ?? noData , previousLowVal?.ToString("N0") ?? noData , (selectedLowVal.HasValue && previousLowVal.HasValue) ? FormatEvolution((int)(selectedLowVal.Value - previousLowVal.Value)) : noData , (selectedLowVal.HasValue && previousLowVal.HasValue && Math.Abs(previousLowVal.Value) > 0) ? FormatPercent((selectedLowVal - previousLowVal) / previousLowVal) : noData , (selectedLowVal.HasValue && selectedTotal.Value > 0) ? FormatPercent(selectedLowVal / selectedTotal, false) : noData }); rowData.AddRange(new[] { Labels.ComplexityAverage , selectedAveVal?.ToString("N0") ?? noData , previousAveVal?.ToString("N0") ?? noData , (selectedAveVal.HasValue && previousAveVal.HasValue) ? FormatEvolution((int)(selectedAveVal.Value - previousAveVal.Value)) : noData , (selectedAveVal.HasValue && previousAveVal.HasValue && Math.Abs(previousAveVal.Value) > 0) ? FormatPercent((selectedAveVal - previousAveVal) / previousAveVal) : noData , (selectedAveVal.HasValue && selectedTotal.Value > 0) ? FormatPercent(selectedAveVal / selectedTotal, false): noData }); rowData.AddRange(new[] { Labels.ComplexityHigh , selectedHigVal?.ToString("N0") ?? noData , previousHigVal?.ToString("N0") ?? noData , (selectedHigVal.HasValue && previousHigVal.HasValue) ? FormatEvolution((int)(selectedHigVal.Value - previousHigVal.Value)) : noData , (selectedHigVal.HasValue && previousHigVal.HasValue && Math.Abs(previousHigVal.Value) > 0) ? FormatPercent((selectedHigVal - previousHigVal) / previousHigVal) : noData , (selectedHigVal.HasValue && selectedTotal.Value > 0) ? FormatPercent(selectedHigVal / selectedTotal, false): noData }); rowData.AddRange(new[] { Labels.ComplexityVeryHigh , selectedVhiVal?.ToString("N0") ?? noData , previousVhiVal?.ToString("N0") ?? noData , previousVhiVal.HasValue && selectedVhiVal.HasValue ? FormatEvolution((int)(selectedVhiVal.Value - previousVhiVal.Value)): noData , (selectedVhiVal.HasValue && previousVhiVal.HasValue && Math.Abs(previousVhiVal.Value) > 0)? FormatPercent((selectedVhiVal - previousVhiVal) / previousVhiVal) : noData , (selectedVhiVal.HasValue && selectedTotal.HasValue && selectedTotal.Value > 0) ? FormatPercent(selectedVhiVal / selectedTotal, false): noData }); #endregion Data back = new TableDefinition { HasRowHeaders = false, HasColumnHeaders = true, Data = rowData, NbColumns = 6, NbRows = 5 }; return(back); }
public override TableDefinition Content(ReportData reportData, Dictionary <string, string> options) { if (reportData?.CurrentSnapshot == null) { return(null); } double?criticalViolation = MeasureUtility.GetSizingMeasure(reportData.CurrentSnapshot, Constants.SizingInformations.ViolationsToCriticalQualityRulesNumber); double?numCritPerFile = MeasureUtility.GetSizingMeasure(reportData.CurrentSnapshot, Constants.SizingInformations.ViolationsToCriticalQualityRulesPerFileNumber); double?_numCritPerKloc = MeasureUtility.GetSizingMeasure(reportData.CurrentSnapshot, Constants.SizingInformations.ViolationsToCriticalQualityRulesPerKLOCNumber); double?veryHighCostComplexityViolations = CastComplexityUtility.GetCostComplexityGrade(reportData.CurrentSnapshot, Constants. QualityDistribution.DistributionOfViolationsToCriticalDiagnosticBasedMetricsPerCostComplexity.GetHashCode(), Constants.ViolationsToCriticalDiagnosticBasedMetricsPerCostComplexity.ComplexityViolations_VeryHigh.GetHashCode()); double?highCostComplexityViolations = CastComplexityUtility.GetCostComplexityGrade(reportData.CurrentSnapshot, Constants.QualityDistribution.DistributionOfViolationsToCriticalDiagnosticBasedMetricsPerCostComplexity.GetHashCode(), Constants.ViolationsToCriticalDiagnosticBasedMetricsPerCostComplexity.ComplexityViolations_HighCost.GetHashCode()); double?veryHighCostComplexityArtefacts = CastComplexityUtility.GetCostComplexityGrade(reportData.CurrentSnapshot, Constants.QualityDistribution.CostComplexityDistribution.GetHashCode(), Constants.CostComplexity.CostComplexityArtifacts_VeryHigh.GetHashCode()); double?highCostComplexityArtefacts = CastComplexityUtility.GetCostComplexityGrade(reportData.CurrentSnapshot, Constants.QualityDistribution.CostComplexityDistribution.GetHashCode(), Constants.CostComplexity.CostComplexityArtifacts_High.GetHashCode()); double?nbComplexityArtefacts = MathUtility.GetSum(veryHighCostComplexityArtefacts, highCostComplexityArtefacts); double?nbComplexityArtefactsViolation = MathUtility.GetSum(veryHighCostComplexityViolations, highCostComplexityViolations); const string metricFormat = "N0"; const string metricFormatPrecision = "N2"; string numCritPerFileIfNegative; // ReSharper disable once CompareOfFloatsByEqualityOperator -- special case if (numCritPerFile == -1) { numCritPerFileIfNegative = Constants.No_Value; } else { numCritPerFileIfNegative = numCritPerFile?.ToString(metricFormatPrecision) ?? Constants.No_Value; } var rowData = new List <string>() { Labels.Name , Labels.Value , Labels.ViolationsCritical , criticalViolation?.ToString(metricFormat) ?? Constants.No_Value , " " + Labels.PerFile , numCritPerFileIfNegative , " " + Labels.PerkLoC , _numCritPerKloc?.ToString(metricFormatPrecision) ?? Constants.No_Value , Labels.ComplexObjects , nbComplexityArtefacts?.ToString(metricFormat) ?? Constants.No_Value , " " + Labels.WithViolations , nbComplexityArtefactsViolation?.ToString(metricFormat) ?? Constants.No_Value }; var resultTable = new TableDefinition { HasRowHeaders = true, HasColumnHeaders = false, NbRows = 6, NbColumns = 2, Data = rowData }; return(resultTable); }
public override TableDefinition Content(ReportData reportData, Dictionary <string, string> options) { const string metricFormat = "N0"; if (reportData?.CurrentSnapshot == null) { return(null); } #region currentSnapshot double?criticalViolation = MeasureUtility.GetSizingMeasure(reportData.CurrentSnapshot, Constants.SizingInformations.ViolationsToCriticalQualityRulesNumber); double?numCritPerFile = MeasureUtility.GetSizingMeasure(reportData.CurrentSnapshot, Constants.SizingInformations.ViolationsToCriticalQualityRulesPerFileNumber); string numCritPerFileIfNegative; // ReSharper disable once CompareOfFloatsByEqualityOperator -- special case if (numCritPerFile == -1) { numCritPerFileIfNegative = Constants.No_Value; } else { numCritPerFileIfNegative = numCritPerFile?.ToString("N2") ?? Constants.No_Value; } double?_numCritPerKloc = MeasureUtility.GetSizingMeasure(reportData.CurrentSnapshot, Constants.SizingInformations.ViolationsToCriticalQualityRulesPerKLOCNumber); double?veryHighCostComplexityViolations = CastComplexityUtility.GetCostComplexityGrade(reportData.CurrentSnapshot, Constants. QualityDistribution.DistributionOfViolationsToCriticalDiagnosticBasedMetricsPerCostComplexity.GetHashCode(), Constants.ViolationsToCriticalDiagnosticBasedMetricsPerCostComplexity. ComplexityViolations_VeryHigh.GetHashCode()); double?highCostComplexityViolations = CastComplexityUtility.GetCostComplexityGrade(reportData.CurrentSnapshot, Constants.QualityDistribution.DistributionOfViolationsToCriticalDiagnosticBasedMetricsPerCostComplexity.GetHashCode(), Constants.ViolationsToCriticalDiagnosticBasedMetricsPerCostComplexity.ComplexityViolations_HighCost.GetHashCode()); double?veryHighCostComplexityArtefacts = CastComplexityUtility.GetCostComplexityGrade(reportData.CurrentSnapshot, Constants.QualityDistribution.CostComplexityDistribution.GetHashCode(), Constants.CostComplexity.CostComplexityArtifacts_VeryHigh.GetHashCode()); double?highCostComplexityArtefacts = CastComplexityUtility.GetCostComplexityGrade(reportData.CurrentSnapshot, Constants.QualityDistribution.CostComplexityDistribution.GetHashCode(), Constants.CostComplexity.CostComplexityArtifacts_High.GetHashCode()); #endregion currentSnapshot #region PreviousSnapshot double?criticalViolationPrev = MeasureUtility.GetSizingMeasure(reportData.PreviousSnapshot, Constants.SizingInformations.ViolationsToCriticalQualityRulesNumber); double?numCritPerFilePrev = MeasureUtility.GetSizingMeasure(reportData.PreviousSnapshot, Constants.SizingInformations.ViolationsToCriticalQualityRulesPerFileNumber); string numCritPerFilePrevIfNegative; // ReSharper disable once CompareOfFloatsByEqualityOperator -- special case if (numCritPerFilePrev == -1) { numCritPerFilePrevIfNegative = Constants.No_Value; } else { numCritPerFilePrevIfNegative = numCritPerFilePrev?.ToString("N2") ?? Constants.No_Value; } double?_numCritPerKlocPrev = MeasureUtility.GetSizingMeasure(reportData.PreviousSnapshot, Constants.SizingInformations.ViolationsToCriticalQualityRulesPerKLOCNumber); double?veryHighCostComplexityViolationsPrev = CastComplexityUtility.GetCostComplexityGrade(reportData.PreviousSnapshot, Constants.QualityDistribution.DistributionOfViolationsToCriticalDiagnosticBasedMetricsPerCostComplexity.GetHashCode(), Constants.ViolationsToCriticalDiagnosticBasedMetricsPerCostComplexity.ComplexityViolations_VeryHigh.GetHashCode()); double?highCostComplexityViolationsPrev = CastComplexityUtility.GetCostComplexityGrade(reportData.PreviousSnapshot, Constants.QualityDistribution.DistributionOfViolationsToCriticalDiagnosticBasedMetricsPerCostComplexity.GetHashCode(), Constants.ViolationsToCriticalDiagnosticBasedMetricsPerCostComplexity.ComplexityViolations_HighCost.GetHashCode()); double?veryHighCostComplexityArtefactsPrev = CastComplexityUtility.GetCostComplexityGrade(reportData.PreviousSnapshot, Constants.QualityDistribution.CostComplexityDistribution.GetHashCode(), Constants.CostComplexity.CostComplexityArtifacts_VeryHigh.GetHashCode()); double?highCostComplexityArtefactsPrev = CastComplexityUtility.GetCostComplexityGrade(reportData.PreviousSnapshot, Constants.QualityDistribution.CostComplexityDistribution.GetHashCode(), Constants.CostComplexity.CostComplexityArtifacts_High.GetHashCode()); #endregion PreviousSnapshot #region SumMetric double?_highveryHighCostComplexityArtefacts = MathUtility.GetSum(veryHighCostComplexityArtefacts, highCostComplexityArtefacts); double?_highveryHighCostComplexityViolations = MathUtility.GetSum(veryHighCostComplexityViolations, highCostComplexityViolations); double?_highveryHighCostComplexityArtefactsPrev = MathUtility.GetSum(veryHighCostComplexityArtefactsPrev, highCostComplexityArtefactsPrev); double?_highveryHighCostComplexityViolationsPrev = MathUtility.GetSum(veryHighCostComplexityViolationsPrev, highCostComplexityViolationsPrev); #endregion SumMetric #region evolutionPercMetric double?criticalViolationEvolPerc = MathUtility.GetVariationPercent(criticalViolation, criticalViolationPrev); double?numCritPerFileEvolPerc = MathUtility.GetVariationPercent(numCritPerFile, numCritPerFilePrev); double?_numCritPerKlocEvolPerc = MathUtility.GetVariationPercent(_numCritPerKloc, _numCritPerKlocPrev); double?_highveryHighCostComplexityViolationsEvolPerc = MathUtility.GetVariationPercent(_highveryHighCostComplexityViolations, _highveryHighCostComplexityViolationsPrev); double?_highveryHighCostComplexityArtefactsEvolPerc = MathUtility.GetVariationPercent(_highveryHighCostComplexityArtefacts, _highveryHighCostComplexityArtefactsPrev); #endregion evolutionPercMetric var rowData = new List <string>() { Labels.Name , Labels.Current , Labels.Previous , Labels.EvolutionPercent , Labels.ViolationsCritical , criticalViolation?.ToString(metricFormat) ?? Constants.No_Value , criticalViolationPrev?.ToString(metricFormat) ?? Constants.No_Value , (criticalViolationEvolPerc.HasValue) ? FormatPercent(criticalViolationEvolPerc.Value): Constants.No_Value , " " + Labels.PerFile , numCritPerFileIfNegative , numCritPerFilePrevIfNegative , (numCritPerFileEvolPerc.HasValue) ? FormatPercent(numCritPerFileEvolPerc.Value) : Constants.No_Value , " " + Labels.PerkLoC , _numCritPerKloc?.ToString("N2") ?? Constants.No_Value , _numCritPerKlocPrev?.ToString("N2") ?? Constants.No_Value , (_numCritPerKlocEvolPerc.HasValue) ? FormatPercent(_numCritPerKlocEvolPerc.Value) : Constants.No_Value , Labels.ComplexObjects , _highveryHighCostComplexityArtefacts?.ToString(metricFormat) ?? Constants.No_Value , _highveryHighCostComplexityArtefactsPrev?.ToString(metricFormat) ?? Constants.No_Value , _highveryHighCostComplexityArtefactsEvolPerc.HasValue ? FormatPercent(_highveryHighCostComplexityArtefactsEvolPerc.Value) : Constants.No_Value , " " + Labels.WithViolations , _highveryHighCostComplexityViolations?.ToString(metricFormat) ?? Constants.No_Value , _highveryHighCostComplexityViolationsPrev?.ToString(metricFormat) ?? Constants.No_Value , _highveryHighCostComplexityViolationsEvolPerc.HasValue ? FormatPercent(_highveryHighCostComplexityViolationsEvolPerc.Value) : Constants.No_Value }; var resultTable = new TableDefinition { HasRowHeaders = true, HasColumnHeaders = false, NbRows = 6, NbColumns = 4, Data = rowData }; return(resultTable); }
/// <summary> /// /// </summary> /// <param name="reportData"></param> /// <param name="options"></param> /// <returns></returns> protected override TableDefinition Content(ReportData reportData, Dictionary <string, string> options) { TableDefinition back = new TableDefinition(); int parId = -1; Constants.QualityDistribution distributionId; List <string> rowData = new List <string>(); double?previousHigVal = null; double?previousVhiVal = null; double?previousHttVal = null; if (null != options && options.ContainsKey("PAR") && Int32.TryParse(options["PAR"], out parId) && Enum.IsDefined(typeof(Constants.QualityDistribution), parId)) { distributionId = (Constants.QualityDistribution)parId; } else { distributionId = Constants.QualityDistribution.CostComplexityDistribution; } if (null != reportData) { #region Selected Snapshot double?selectedLowVal = CastComplexityUtility.GetCostComplexityGrade(reportData.CurrentSnapshot, distributionId.GetHashCode(), Constants.CyclomaticComplexity.ComplexityArtifacts_Low.GetHashCode()); double?selectedAveVal = CastComplexityUtility.GetCostComplexityGrade(reportData.CurrentSnapshot, distributionId.GetHashCode(), Constants.CyclomaticComplexity.ComplexityArtifacts_Moderate.GetHashCode()); double?selectedHigVal = CastComplexityUtility.GetCostComplexityGrade(reportData.CurrentSnapshot, distributionId.GetHashCode(), Constants.CyclomaticComplexity.ComplexityArtifacts_High.GetHashCode()); double?selectedVhiVal = CastComplexityUtility.GetCostComplexityGrade(reportData.CurrentSnapshot, distributionId.GetHashCode(), Constants.CyclomaticComplexity.ComplexityArtifacts_VeryHigh.GetHashCode()); double?selectedTotal = (selectedLowVal.HasValue && selectedAveVal.HasValue && selectedHigVal.HasValue && selectedVhiVal.HasValue) ? selectedLowVal.Value + selectedAveVal.Value + selectedHigVal.Value + selectedVhiVal.Value : (double?)null; double?selectedHttVal = (selectedHigVal.HasValue && selectedVhiVal.HasValue) ? selectedHigVal.Value + selectedVhiVal.Value : (double?)null; #endregion Selected Snapshot #region Previous Snapshot if (reportData.PreviousSnapshot != null) { previousHigVal = CastComplexityUtility.GetCostComplexityGrade(reportData.PreviousSnapshot, distributionId.GetHashCode(), Constants.CyclomaticComplexity.ComplexityArtifacts_High.GetHashCode()); previousVhiVal = CastComplexityUtility.GetCostComplexityGrade(reportData.PreviousSnapshot, distributionId.GetHashCode(), Constants.CyclomaticComplexity.ComplexityArtifacts_VeryHigh.GetHashCode()); previousHttVal = previousHigVal.HasValue && previousVhiVal.HasValue ? previousHigVal.Value + previousVhiVal.Value : (double?)null; } #endregion Previous Snapshot #region Data Int32?variation = (selectedHttVal.HasValue && previousHttVal.HasValue) ? (Int32)(selectedHttVal - previousHttVal) : (Int32?)null; string distributionName = CastComplexityUtility.GetCostComplexityName(reportData.CurrentSnapshot, distributionId.GetHashCode()); rowData.AddRange(new string[] { distributionName, Labels.Current, Labels.Previous, Labels.Evol, Labels.TotalPercent }); rowData.AddRange(new string[] { Labels.ComplexityHighAndVeryHigh , selectedHttVal.HasValue? selectedHttVal.Value.ToString(_MetricFormat) : Constants.No_Value , previousHttVal.HasValue ? previousHttVal.Value.ToString(_MetricFormat) : Constants.No_Value , variation.HasValue? TableBlock.FormatEvolution((Int32)variation.Value): Constants.No_Value , (selectedHttVal.HasValue && selectedTotal.HasValue && selectedTotal.Value > 0)? TableBlock.FormatPercent(selectedHttVal.Value / selectedTotal.Value, false): Constants.No_Value }); #endregion Data back = new TableDefinition { Data = rowData, HasRowHeaders = false, HasColumnHeaders = true, NbColumns = 5, NbRows = 2 }; } return(back); }
protected override TableDefinition Content(ReportData reportData, Dictionary <string, string> options) { List <string> rowData = new List <string>(); bool hasPreviousSnapshot = (null != reportData.PreviousSnapshot); string previousName = String.Empty, selectedName = String.Empty; double?selectedLowVal = null; double?selectedAveVal = null; double?selectedHigVal = null; double?selectedVhiVal = null; double?previousLowVal = null; double?previousAveVal = null; double?previousHigVal = null; double?previousVhiVal = null; if (reportData != null && reportData.CurrentSnapshot != null) { #region Selected Snapshot selectedName = reportData.CurrentSnapshot.Annotation.Version; selectedLowVal = CastComplexityUtility.GetCostComplexityGrade(reportData.CurrentSnapshot, Constants.QualityDistribution.CostComplexityDistribution.GetHashCode(), Constants.CostComplexity.CostComplexityArtifacts_Low.GetHashCode()); selectedAveVal = CastComplexityUtility.GetCostComplexityGrade(reportData.CurrentSnapshot, Constants.QualityDistribution.CostComplexityDistribution.GetHashCode(), Constants.CostComplexity.CostComplexityArtifacts_Average.GetHashCode()); selectedHigVal = CastComplexityUtility.GetCostComplexityGrade(reportData.CurrentSnapshot, Constants.QualityDistribution.CostComplexityDistribution.GetHashCode(), Constants.CostComplexity.CostComplexityArtifacts_High.GetHashCode()); selectedVhiVal = CastComplexityUtility.GetCostComplexityGrade(reportData.CurrentSnapshot, Constants.QualityDistribution.CostComplexityDistribution.GetHashCode(), Constants.CostComplexity.CostComplexityArtifacts_VeryHigh.GetHashCode()); #endregion Selected Snapshot #region Previous Snapshot previousName = hasPreviousSnapshot ? reportData.PreviousSnapshot.Annotation.Version : "No previous snapshot selected"; if (hasPreviousSnapshot) { previousLowVal = CastComplexityUtility.GetCostComplexityGrade(reportData.PreviousSnapshot, Constants.QualityDistribution.CostComplexityDistribution.GetHashCode(), Constants.CostComplexity.CostComplexityArtifacts_Low.GetHashCode()); previousAveVal = CastComplexityUtility.GetCostComplexityGrade(reportData.PreviousSnapshot, Constants.QualityDistribution.CostComplexityDistribution.GetHashCode(), Constants.CostComplexity.CostComplexityArtifacts_Average.GetHashCode()); previousHigVal = CastComplexityUtility.GetCostComplexityGrade(reportData.PreviousSnapshot, Constants.QualityDistribution.CostComplexityDistribution.GetHashCode(), Constants.CostComplexity.CostComplexityArtifacts_High.GetHashCode()); previousVhiVal = CastComplexityUtility.GetCostComplexityGrade(reportData.PreviousSnapshot, Constants.QualityDistribution.CostComplexityDistribution.GetHashCode(), Constants.CostComplexity.CostComplexityArtifacts_VeryHigh.GetHashCode()); } #endregion Previous Snapshot #region Data rowData.Add(" "); rowData.Add(selectedName); if (hasPreviousSnapshot) { rowData.Add(previousName); } rowData.Add(" "); rowData.Add("0"); if (hasPreviousSnapshot) { rowData.Add("0"); } rowData.Add(Labels.CplxLow); rowData.Add(selectedLowVal.GetValueOrDefault().ToString()); if (hasPreviousSnapshot) { rowData.Add(previousLowVal.GetValueOrDefault().ToString()); } rowData.Add(Labels.CplxAverage); rowData.Add(selectedAveVal.GetValueOrDefault().ToString()); if (hasPreviousSnapshot) { rowData.Add(previousAveVal.GetValueOrDefault().ToString()); } rowData.Add(Labels.CplxHigh); rowData.Add(selectedHigVal.GetValueOrDefault().ToString()); if (hasPreviousSnapshot) { rowData.Add(previousHigVal.GetValueOrDefault().ToString()); } rowData.Add(Labels.CplxVeryHigh); rowData.Add(selectedVhiVal.GetValueOrDefault().ToString()); if (hasPreviousSnapshot) { rowData.Add(previousVhiVal.GetValueOrDefault().ToString()); } rowData.Add(" "); rowData.Add("0"); if (hasPreviousSnapshot) { rowData.Add("0"); } #endregion Data } TableDefinition back = new TableDefinition { Data = rowData, HasRowHeaders = false, HasColumnHeaders = false, NbColumns = hasPreviousSnapshot ? 3 : 2, NbRows = 7 }; return(back); }
public override TableDefinition Content(ReportData reportData, Dictionary <string, string> options) { TableDefinition result = new TableDefinition(); List <string> rowData = new List <string>(); int parId; Constants.QualityDistribution distributionId; double?selectedTotal = null; if (null != options && options.ContainsKey("PAR") && int.TryParse(options["PAR"], out parId) && Enum.IsDefined(typeof(Constants.QualityDistribution), parId)) { distributionId = (Constants.QualityDistribution)parId; } else { distributionId = Constants.QualityDistribution.CostComplexityDistribution; } if (reportData?.CurrentSnapshot == null) { return(result); } #region Selected Snapshot var selectedLowVal = CastComplexityUtility.GetCostComplexityGrade(reportData.CurrentSnapshot, distributionId.GetHashCode(), "low"); var selectedAveVal = CastComplexityUtility.GetCostComplexityGrade(reportData.CurrentSnapshot, distributionId.GetHashCode(), "average"); var selectedHigVal = CastComplexityUtility.GetCostComplexityGrade(reportData.CurrentSnapshot, distributionId.GetHashCode(), "high"); var selectedVhiVal = CastComplexityUtility.GetCostComplexityGrade(reportData.CurrentSnapshot, distributionId.GetHashCode(), "very_high"); if (selectedLowVal.HasValue && selectedAveVal.HasValue && selectedHigVal.HasValue && selectedVhiVal.HasValue) { selectedTotal = selectedLowVal + selectedAveVal + selectedHigVal + selectedVhiVal; } #endregion Selected Snapshot #region Previous Snapshot double?previousLowVal = null; double?previousAveVal = null; double?previousHigVal = null; double?previousVhiVal = null; if (reportData.PreviousSnapshot != null) { previousLowVal = CastComplexityUtility.GetCostComplexityGrade(reportData.PreviousSnapshot, distributionId.GetHashCode(), "low"); previousAveVal = CastComplexityUtility.GetCostComplexityGrade(reportData.PreviousSnapshot, distributionId.GetHashCode(), "average"); previousHigVal = CastComplexityUtility.GetCostComplexityGrade(reportData.PreviousSnapshot, distributionId.GetHashCode(), "high"); previousVhiVal = CastComplexityUtility.GetCostComplexityGrade(reportData.PreviousSnapshot, distributionId.GetHashCode(), "very_high"); } #endregion Previous Snapshot #region Data var distributionName = CastComplexityUtility.GetCostComplexityName(reportData.CurrentSnapshot, distributionId.GetHashCode()); rowData.AddRange(new[] { distributionName, Labels.Current, Labels.Previous, Labels.Evol, Labels.EvolPercent, Labels.TotalPercent }); rowData.AddRange(new[] { Labels.ComplexityLow , selectedLowVal?.ToString("N0") ?? Constants.No_Value , previousLowVal?.ToString("N0") ?? Constants.No_Value , (selectedLowVal.HasValue && previousLowVal.HasValue) ? FormatEvolution((int)(selectedLowVal.Value - previousLowVal.Value)): Constants.No_Value , (selectedLowVal.HasValue && previousLowVal.HasValue && Math.Abs(previousLowVal.Value) > 0)? FormatPercent((selectedLowVal - previousLowVal) / previousLowVal): Constants.No_Value , (selectedLowVal.HasValue && selectedTotal.HasValue && selectedTotal.Value > 0)?FormatPercent(selectedLowVal / selectedTotal, false): Constants.No_Value }); rowData.AddRange(new[] { Labels.ComplexityAverage , selectedAveVal?.ToString("N0") ?? Constants.No_Value , previousAveVal?.ToString("N0") ?? Constants.No_Value , (selectedAveVal.HasValue && previousAveVal.HasValue) ? FormatEvolution((int)(selectedAveVal.Value - previousAveVal.Value)) : Constants.No_Value , (selectedAveVal.HasValue && previousAveVal.HasValue && Math.Abs(previousAveVal.Value) > 0)? FormatPercent((selectedAveVal - previousAveVal) / previousAveVal): Constants.No_Value , (selectedAveVal.HasValue && selectedTotal.HasValue && selectedTotal.Value > 0)?FormatPercent(selectedAveVal / selectedTotal, false): Constants.No_Value }); rowData.AddRange(new[] { Labels.ComplexityHigh , selectedHigVal?.ToString("N0") ?? Constants.No_Value , previousHigVal?.ToString("N0") ?? Constants.No_Value , previousHigVal.HasValue ? FormatEvolution((int)(selectedHigVal.Value - previousHigVal.Value)): Constants.No_Value , (selectedHigVal.HasValue && previousHigVal.HasValue && Math.Abs(previousHigVal.Value) > 0)? FormatPercent((selectedHigVal - previousHigVal) / previousHigVal): Constants.No_Value , (selectedHigVal.HasValue && selectedTotal.HasValue && selectedTotal.Value > 0)?FormatPercent(selectedHigVal / selectedTotal, false): Constants.No_Value }); rowData.AddRange(new[] { Labels.ComplexityExtreme , selectedVhiVal?.ToString("N0") ?? Constants.No_Value , previousVhiVal?.ToString("N0") ?? Constants.No_Value , (selectedVhiVal.HasValue && previousVhiVal.HasValue) ? FormatEvolution((int)(selectedVhiVal.Value - previousVhiVal.Value)): Constants.No_Value , (selectedVhiVal.HasValue && previousVhiVal.HasValue && Math.Abs(previousVhiVal.Value) > 0)? FormatPercent((selectedVhiVal - previousVhiVal) / previousVhiVal): Constants.No_Value , (selectedVhiVal.HasValue && selectedTotal.HasValue && selectedTotal.Value > 0)?FormatPercent(selectedVhiVal / selectedTotal, false): Constants.No_Value }); #endregion Data result = new TableDefinition { Data = rowData, HasRowHeaders = false, HasColumnHeaders = true, NbColumns = 6, NbRows = 5 }; return(result); }
public override TableDefinition Content(ReportData reportData, Dictionary <string, string> options) { List <string> rowData = new List <string>(); int parId; Constants.QualityDistribution distributionId; double?previousLowVal = null; double?previousAveVal = null; double?previousHigVal = null; double?previousVhiVal = null; bool hasPreviousSnapshot = (null != reportData.PreviousSnapshot); string previousName = string.Empty; if (null != options && options.ContainsKey("PAR") && int.TryParse(options["PAR"], out parId) && Enum.IsDefined(typeof(Constants.QualityDistribution), parId)) { distributionId = (Constants.QualityDistribution)parId; } else { distributionId = Constants.QualityDistribution.CostComplexityDistribution; } if (reportData.CurrentSnapshot != null) { var selectedName = reportData.CurrentSnapshot.Annotation.Version; #region Selected Snapshot var selectedLowVal = CastComplexityUtility.GetCostComplexityGrade(reportData.CurrentSnapshot, distributionId.GetHashCode(), "low"); var selectedAveVal = CastComplexityUtility.GetCostComplexityGrade(reportData.CurrentSnapshot, distributionId.GetHashCode(), "average"); var selectedHigVal = CastComplexityUtility.GetCostComplexityGrade(reportData.CurrentSnapshot, distributionId.GetHashCode(), "high"); var selectedVhiVal = CastComplexityUtility.GetCostComplexityGrade(reportData.CurrentSnapshot, distributionId.GetHashCode(), "very_high"); #endregion Selected Snapshot #region Previous Snapshot if (hasPreviousSnapshot) { previousName = reportData.PreviousSnapshot.Annotation.Version; previousLowVal = CastComplexityUtility.GetCostComplexityGrade(reportData.PreviousSnapshot, distributionId.GetHashCode(), "low"); previousAveVal = CastComplexityUtility.GetCostComplexityGrade(reportData.PreviousSnapshot, distributionId.GetHashCode(), "average"); previousHigVal = CastComplexityUtility.GetCostComplexityGrade(reportData.PreviousSnapshot, distributionId.GetHashCode(), "high"); previousVhiVal = CastComplexityUtility.GetCostComplexityGrade(reportData.PreviousSnapshot, distributionId.GetHashCode(), "very_high"); } #endregion Previous Snapshot #region Data rowData.Add(" "); rowData.Add(selectedName); if (hasPreviousSnapshot) { rowData.Add(previousName); } rowData.Add(" "); rowData.Add("0"); if (hasPreviousSnapshot) { rowData.Add("0"); } rowData.Add(Labels.CplxLow); rowData.Add(selectedLowVal.GetValueOrDefault().ToString(CultureInfo.CurrentCulture)); if (hasPreviousSnapshot) { rowData.Add(previousLowVal.GetValueOrDefault().ToString(CultureInfo.CurrentCulture)); } rowData.Add(Labels.CplxAverage); rowData.Add(selectedAveVal.GetValueOrDefault().ToString(CultureInfo.CurrentCulture)); if (hasPreviousSnapshot) { rowData.Add(previousAveVal.GetValueOrDefault().ToString(CultureInfo.CurrentCulture)); } rowData.Add(Labels.CplxHigh); rowData.Add(selectedHigVal.GetValueOrDefault().ToString(CultureInfo.CurrentCulture)); if (hasPreviousSnapshot) { rowData.Add(previousHigVal.GetValueOrDefault().ToString(CultureInfo.CurrentCulture)); } rowData.Add(Labels.CplxVeryHigh); rowData.Add(selectedVhiVal.GetValueOrDefault().ToString(CultureInfo.CurrentCulture)); if (hasPreviousSnapshot) { rowData.Add(previousVhiVal.GetValueOrDefault().ToString(CultureInfo.CurrentCulture)); } rowData.Add(" "); rowData.Add("0"); if (hasPreviousSnapshot) { rowData.Add("0"); } #endregion Data } var result = new TableDefinition { Data = rowData, HasRowHeaders = false, HasColumnHeaders = false, NbColumns = hasPreviousSnapshot ? 3 : 2, NbRows = 7 }; return(result); }
/// <summary> /// /// </summary> /// <param name="reportData"></param> /// <param name="options"></param> /// <returns></returns> public override TableDefinition Content(ReportData reportData, Dictionary <string, string> options) { TableDefinition back = new TableDefinition(); int parId; Constants.QualityDistribution distributionId; List <string> rowData = new List <string>(); double?previousHttVal = null; if (null != options && options.ContainsKey("PAR") && int.TryParse(options["PAR"], out parId) && Enum.IsDefined(typeof(Constants.QualityDistribution), parId)) { distributionId = (Constants.QualityDistribution)parId; } else { distributionId = Constants.QualityDistribution.CostComplexityDistribution; } if (null == reportData) { return(back); } #region Selected Snapshot double?selectedLowVal = CastComplexityUtility.GetCostComplexityGrade(reportData.CurrentSnapshot, distributionId.GetHashCode(), "low"); double?selectedAveVal = CastComplexityUtility.GetCostComplexityGrade(reportData.CurrentSnapshot, distributionId.GetHashCode(), "average"); double?selectedHigVal = CastComplexityUtility.GetCostComplexityGrade(reportData.CurrentSnapshot, distributionId.GetHashCode(), "high"); double?selectedVhiVal = CastComplexityUtility.GetCostComplexityGrade(reportData.CurrentSnapshot, distributionId.GetHashCode(), "very_high"); double?selectedTotal = (selectedLowVal.HasValue && selectedAveVal.HasValue && selectedHigVal.HasValue && selectedVhiVal.HasValue) ? selectedLowVal.Value + selectedAveVal.Value + selectedHigVal.Value + selectedVhiVal.Value : (double?)null; double?selectedHttVal = (selectedHigVal.HasValue && selectedVhiVal.HasValue) ? selectedHigVal.Value + selectedVhiVal.Value : (double?)null; #endregion Selected Snapshot #region Previous Snapshot if (reportData.PreviousSnapshot != null) { var previousHigVal = CastComplexityUtility.GetCostComplexityGrade(reportData.PreviousSnapshot, distributionId.GetHashCode(), "high"); var previousVhiVal = CastComplexityUtility.GetCostComplexityGrade(reportData.PreviousSnapshot, distributionId.GetHashCode(), "very_high"); previousHttVal = previousHigVal.HasValue && previousVhiVal.HasValue ? previousHigVal.Value + previousVhiVal.Value : (double?)null; } #endregion Previous Snapshot #region Data int?variation = (selectedHttVal.HasValue && previousHttVal.HasValue) ? (int)(selectedHttVal - previousHttVal) : (int?)null; string distributionName = CastComplexityUtility.GetCostComplexityName(reportData.CurrentSnapshot, distributionId.GetHashCode()); rowData.AddRange(new[] { distributionName, Labels.Current, Labels.Previous, Labels.Evol, Labels.TotalPercent }); rowData.AddRange(new[] { Labels.ComplexityHighAndVeryHigh , selectedHttVal?.ToString(MetricFormat) ?? Constants.No_Value , previousHttVal?.ToString(MetricFormat) ?? Constants.No_Value , variation.HasValue? FormatEvolution(variation.Value): Constants.No_Value , (selectedHttVal.HasValue && selectedTotal.HasValue && selectedTotal.Value > 0)? FormatPercent(selectedHttVal.Value / selectedTotal.Value, false): Constants.No_Value }); #endregion Data back = new TableDefinition { Data = rowData, HasRowHeaders = false, HasColumnHeaders = true, NbColumns = 5, NbRows = 2 }; return(back); }
public override TableDefinition Content(ReportData reportData, Dictionary <string, string> options) { TableDefinition back = new TableDefinition(); List <string> rowData = new List <string>(); const string numberFormat = "N0"; if (reportData?.CurrentSnapshot?.CostComplexityResults == null) { return(back); } #region Selected Snapshot double?nbArtifactLow = CastComplexityUtility.GetCostComplexityGrade(reportData.CurrentSnapshot, Constants.QualityDistribution.CostComplexityDistribution.GetHashCode(), Constants.CostComplexity.CostComplexityArtifacts_Low.GetHashCode()); double?nbArtifactAve = CastComplexityUtility.GetCostComplexityGrade(reportData.CurrentSnapshot, Constants.QualityDistribution.CostComplexityDistribution.GetHashCode(), Constants.CostComplexity.CostComplexityArtifacts_Average.GetHashCode()); double?nbArtifactHigh = CastComplexityUtility.GetCostComplexityGrade(reportData.CurrentSnapshot, Constants.QualityDistribution.CostComplexityDistribution.GetHashCode(), Constants.CostComplexity.CostComplexityArtifacts_High.GetHashCode()); double?nbArtifactVeryHigh = CastComplexityUtility.GetCostComplexityGrade(reportData.CurrentSnapshot, Constants.QualityDistribution.CostComplexityDistribution.GetHashCode(), Constants.CostComplexity.CostComplexityArtifacts_VeryHigh.GetHashCode()); double?nbViolationLow = CastComplexityUtility.GetCostComplexityGrade(reportData.CurrentSnapshot, Constants.QualityDistribution.DistributionOfDefectsToCriticalDiagnosticBasedMetricsPerCostComplexity.GetHashCode(), Constants.DefectsToCriticalDiagnosticBasedMetricsPerCostComplexity.CostComplexityDefects_Low.GetHashCode()); double?nbViolationAve = CastComplexityUtility.GetCostComplexityGrade(reportData.CurrentSnapshot, Constants.QualityDistribution.DistributionOfDefectsToCriticalDiagnosticBasedMetricsPerCostComplexity.GetHashCode(), Constants.DefectsToCriticalDiagnosticBasedMetricsPerCostComplexity.CostComplexityDefects_Average.GetHashCode()); double?nbViolationHigh = CastComplexityUtility.GetCostComplexityGrade(reportData.CurrentSnapshot, Constants.QualityDistribution.DistributionOfDefectsToCriticalDiagnosticBasedMetricsPerCostComplexity.GetHashCode(), Constants.DefectsToCriticalDiagnosticBasedMetricsPerCostComplexity.CostComplexityDefects_High.GetHashCode()); double?nbViolationVeryHigh = CastComplexityUtility.GetCostComplexityGrade(reportData.CurrentSnapshot, Constants.QualityDistribution.DistributionOfDefectsToCriticalDiagnosticBasedMetricsPerCostComplexity.GetHashCode(), Constants.DefectsToCriticalDiagnosticBasedMetricsPerCostComplexity.CostComplexityDefects_VeryHigh.GetHashCode()); #endregion Selected Snapshot #region Data rowData.AddRange(new[] { Labels.Complexity, Labels.Artifacts, Labels.WithViolations }); rowData.AddRange(new[] { Labels.CplxExtreme, nbArtifactVeryHigh?.ToString(numberFormat) ?? Constants.No_Value, nbViolationVeryHigh?.ToString(numberFormat) ?? Constants.No_Value }); rowData.AddRange(new[] { Labels.CplxHigh, nbArtifactHigh?.ToString(numberFormat) ?? Constants.No_Value, nbViolationHigh?.ToString(numberFormat) ?? Constants.No_Value }); rowData.AddRange(new[] { Labels.CplxAverage, nbArtifactAve?.ToString(numberFormat) ?? Constants.No_Value, nbViolationAve?.ToString(numberFormat) ?? Constants.No_Value }); rowData.AddRange(new[] { Labels.CplxLow, nbArtifactLow?.ToString(numberFormat) ?? Constants.No_Value, nbViolationLow?.ToString(numberFormat) ?? Constants.No_Value }); #endregion Data back = new TableDefinition { Data = rowData, HasRowHeaders = false, HasColumnHeaders = true, NbColumns = 3, NbRows = 4 }; return(back); }
protected override TableDefinition Content(ReportData reportData, Dictionary <string, string> options) { TableDefinition result = new TableDefinition(); List <string> rowData = new List <string>(); int parId; Constants.QualityDistribution distributionId; double?selectedLowVal = null; double?selectedAveVal = null; double?selectedHigVal = null; double?selectedVhiVal = null; double?selectedTotal = null; double?previousLowVal = null; double?previousAveVal = null; double?previousHigVal = null; double?previousVhiVal = null; string distributionName = Constants.No_Value; if (null != options && options.ContainsKey("PAR") && Int32.TryParse(options["PAR"], out parId) && Enum.IsDefined(typeof(Constants.QualityDistribution), parId)) { distributionId = (Constants.QualityDistribution)parId; } else { distributionId = Constants.QualityDistribution.CostComplexityDistribution; } if (null != reportData && null != reportData.CurrentSnapshot) { #region Selected Snapshot selectedLowVal = CastComplexityUtility.GetCostComplexityGrade(reportData.CurrentSnapshot, distributionId.GetHashCode(), Constants.CyclomaticComplexity.ComplexityArtifacts_Low.GetHashCode()); selectedAveVal = CastComplexityUtility.GetCostComplexityGrade(reportData.CurrentSnapshot, distributionId.GetHashCode(), Constants.CyclomaticComplexity.ComplexityArtifacts_Moderate.GetHashCode()); selectedHigVal = CastComplexityUtility.GetCostComplexityGrade(reportData.CurrentSnapshot, distributionId.GetHashCode(), Constants.CyclomaticComplexity.ComplexityArtifacts_High.GetHashCode()); selectedVhiVal = CastComplexityUtility.GetCostComplexityGrade(reportData.CurrentSnapshot, distributionId.GetHashCode(), Constants.CyclomaticComplexity.ComplexityArtifacts_VeryHigh.GetHashCode()); if (selectedLowVal.HasValue && selectedAveVal.HasValue && selectedHigVal.HasValue && selectedVhiVal.HasValue) { selectedTotal = selectedLowVal + selectedAveVal + selectedHigVal + selectedVhiVal; } #endregion Selected Snapshot #region Previous Snapshot if (reportData.PreviousSnapshot != null) { previousLowVal = CastComplexityUtility.GetCostComplexityGrade(reportData.PreviousSnapshot, distributionId.GetHashCode(), Constants.CyclomaticComplexity.ComplexityArtifacts_Low.GetHashCode()); previousAveVal = CastComplexityUtility.GetCostComplexityGrade(reportData.PreviousSnapshot, distributionId.GetHashCode(), Constants.CyclomaticComplexity.ComplexityArtifacts_Moderate.GetHashCode()); previousHigVal = CastComplexityUtility.GetCostComplexityGrade(reportData.PreviousSnapshot, distributionId.GetHashCode(), Constants.CyclomaticComplexity.ComplexityArtifacts_High.GetHashCode()); previousVhiVal = CastComplexityUtility.GetCostComplexityGrade(reportData.PreviousSnapshot, distributionId.GetHashCode(), Constants.CyclomaticComplexity.ComplexityArtifacts_VeryHigh.GetHashCode()); } #endregion Previous Snapshot #region Data distributionName = CastComplexityUtility.GetCostComplexityName(reportData.CurrentSnapshot, distributionId.GetHashCode()); rowData.AddRange(new string[] { distributionName, Labels.Current, Labels.Previous, Labels.Evol, Labels.EvolPercent, Labels.TotalPercent }); rowData.AddRange(new string[] { Labels.ComplexityLow , selectedLowVal.HasValue ? selectedLowVal.Value.ToString("N0"):Constants.No_Value , previousLowVal.HasValue ? previousLowVal.Value.ToString("N0") : Constants.No_Value , (selectedLowVal.HasValue && previousLowVal.HasValue) ? TableBlock.FormatEvolution((Int32)(selectedLowVal.Value - previousLowVal.Value)): Constants.No_Value , (selectedLowVal.HasValue && previousLowVal.HasValue && previousLowVal.Value != 0)? TableBlock.FormatPercent((selectedLowVal - previousLowVal) / previousLowVal) : Constants.No_Value , (selectedLowVal.HasValue && selectedTotal.HasValue && selectedTotal.Value > 0)?TableBlock.FormatPercent(selectedLowVal / selectedTotal, false): Constants.No_Value }); rowData.AddRange(new string[] { Labels.ComplexityAverage , selectedAveVal.HasValue ? selectedAveVal.Value.ToString("N0"): Constants.No_Value , previousAveVal.HasValue ? previousAveVal.Value.ToString("N0") : Constants.No_Value , (selectedAveVal.HasValue && previousAveVal.HasValue) ? TableBlock.FormatEvolution((Int32)(selectedAveVal.Value - previousAveVal.Value)) : Constants.No_Value , (selectedAveVal.HasValue && previousAveVal.HasValue && previousAveVal.Value != 0)? TableBlock.FormatPercent((selectedAveVal - previousAveVal) / previousAveVal) : Constants.No_Value , (selectedAveVal.HasValue && selectedTotal.HasValue && selectedTotal.Value > 0)?TableBlock.FormatPercent(selectedAveVal / selectedTotal, false): Constants.No_Value }); rowData.AddRange(new string[] { Labels.ComplexityHigh , selectedHigVal.Value.ToString("N0") , previousHigVal.HasValue ? previousHigVal.Value.ToString("N0") : Constants.No_Value , previousHigVal.HasValue ? TableBlock.FormatEvolution((Int32)(selectedHigVal.Value - previousHigVal.Value)): Constants.No_Value , (selectedHigVal.HasValue && previousHigVal.HasValue && previousHigVal.Value != 0)? TableBlock.FormatPercent((selectedHigVal - previousHigVal) / previousHigVal) : Constants.No_Value , (selectedHigVal.HasValue && selectedTotal.HasValue && selectedTotal.Value > 0)?TableBlock.FormatPercent(selectedHigVal / selectedTotal, false): Constants.No_Value }); rowData.AddRange(new string[] { Labels.ComplexityExtreme , selectedVhiVal.HasValue? selectedVhiVal.Value.ToString("N0"): Constants.No_Value , previousVhiVal.HasValue ? previousVhiVal.Value.ToString("N0") : Constants.No_Value , (selectedVhiVal.HasValue && previousVhiVal.HasValue) ? TableBlock.FormatEvolution((Int32)(selectedVhiVal.Value - previousVhiVal.Value)): Constants.No_Value , (selectedVhiVal.HasValue && previousVhiVal.HasValue && previousVhiVal.Value != 0)? TableBlock.FormatPercent((selectedVhiVal - previousVhiVal) / previousVhiVal) : Constants.No_Value , (selectedVhiVal.HasValue && selectedTotal.HasValue && selectedTotal.Value > 0)?TableBlock.FormatPercent(selectedVhiVal / selectedTotal, false): Constants.No_Value }); #endregion Data result = new TableDefinition { Data = rowData, HasRowHeaders = false, HasColumnHeaders = true, NbColumns = 6, NbRows = 5 }; } return(result); }
protected override TableDefinition Content(ReportData reportData, Dictionary <string, string> options) { TableDefinition resultTable = null; const string metricFormat = "N0"; if (reportData != null && reportData.CurrentSnapshot != null) { #region currentSnapshot double?criticalViolation = MeasureUtility.GetSizingMeasure(reportData.CurrentSnapshot, Constants.SizingInformations.ViolationsToCriticalQualityRulesNumber); double?numCritPerFile = MeasureUtility.GetSizingMeasure(reportData.CurrentSnapshot, Constants.SizingInformations.ViolationsToCriticalQualityRulesPerFileNumber); string numCritPerFileIfNegative = string.Empty; if (numCritPerFile == -1) { numCritPerFileIfNegative = "N/A"; } else { numCritPerFileIfNegative = (numCritPerFile.HasValue) ? numCritPerFile.Value.ToString("N2") : CastReporting.Domain.Constants.No_Value; } double?numCritPerKLOC = MeasureUtility.GetSizingMeasure(reportData.CurrentSnapshot, Constants.SizingInformations.ViolationsToCriticalQualityRulesPerKLOCNumber); double?veryHighCostComplexityViolations = CastComplexityUtility.GetCostComplexityGrade(reportData.CurrentSnapshot, Constants. QualityDistribution.DistributionOfViolationsToCriticalDiagnosticBasedMetricsPerCostComplexity.GetHashCode(), Constants.ViolationsToCriticalDiagnosticBasedMetricsPerCostComplexity. ComplexityViolations_VeryHigh.GetHashCode()); double?highCostComplexityViolations = CastComplexityUtility.GetCostComplexityGrade(reportData.CurrentSnapshot, Constants.QualityDistribution.DistributionOfViolationsToCriticalDiagnosticBasedMetricsPerCostComplexity.GetHashCode(), Constants.ViolationsToCriticalDiagnosticBasedMetricsPerCostComplexity.ComplexityViolations_HighCost.GetHashCode()); double?veryHighCostComplexityArtefacts = CastComplexityUtility.GetCostComplexityGrade(reportData.CurrentSnapshot, Constants.QualityDistribution.CostComplexityDistribution.GetHashCode(), Constants.CostComplexity.CostComplexityArtifacts_VeryHigh.GetHashCode()); double?highCostComplexityArtefacts = CastComplexityUtility.GetCostComplexityGrade(reportData.CurrentSnapshot, Constants.QualityDistribution.CostComplexityDistribution.GetHashCode(), Constants.CostComplexity.CostComplexityArtifacts_High.GetHashCode()); #endregion currentSnapshot #region PreviousSnapshot double?criticalViolationPrev = MeasureUtility.GetSizingMeasure(reportData.PreviousSnapshot, Constants.SizingInformations.ViolationsToCriticalQualityRulesNumber); double?numCritPerFilePrev = MeasureUtility.GetSizingMeasure(reportData.PreviousSnapshot, Constants.SizingInformations.ViolationsToCriticalQualityRulesPerFileNumber); string numCritPerFilePrevIfNegative = string.Empty; if (numCritPerFilePrev == -1) { numCritPerFilePrevIfNegative = "N/A"; } else { numCritPerFilePrevIfNegative = (numCritPerFilePrev.HasValue) ? numCritPerFilePrev.Value.ToString("N2") : CastReporting.Domain.Constants.No_Value; } double?numCritPerKLOCPrev = MeasureUtility.GetSizingMeasure(reportData.PreviousSnapshot, Constants.SizingInformations.ViolationsToCriticalQualityRulesPerKLOCNumber); double?veryHighCostComplexityViolationsPrev = CastComplexityUtility.GetCostComplexityGrade(reportData.PreviousSnapshot, Constants.QualityDistribution.DistributionOfViolationsToCriticalDiagnosticBasedMetricsPerCostComplexity.GetHashCode(), Constants.ViolationsToCriticalDiagnosticBasedMetricsPerCostComplexity.ComplexityViolations_VeryHigh.GetHashCode()); double?highCostComplexityViolationsPrev = CastComplexityUtility.GetCostComplexityGrade(reportData.PreviousSnapshot, Constants.QualityDistribution.DistributionOfViolationsToCriticalDiagnosticBasedMetricsPerCostComplexity.GetHashCode(), Constants.ViolationsToCriticalDiagnosticBasedMetricsPerCostComplexity.ComplexityViolations_HighCost.GetHashCode()); double?veryHighCostComplexityArtefactsPrev = CastComplexityUtility.GetCostComplexityGrade(reportData.PreviousSnapshot, Constants.QualityDistribution.CostComplexityDistribution.GetHashCode(), Constants.CostComplexity.CostComplexityArtifacts_VeryHigh.GetHashCode()); double?highCostComplexityArtefactsPrev = CastComplexityUtility.GetCostComplexityGrade(reportData.PreviousSnapshot, Constants.QualityDistribution.CostComplexityDistribution.GetHashCode(), Constants.CostComplexity.CostComplexityArtifacts_High.GetHashCode()); #endregion PreviousSnapshot #region SumMetric double?HighveryHighCostComplexityArtefacts = MathUtility.GetSum(veryHighCostComplexityArtefacts, highCostComplexityArtefacts); double?HighveryHighCostComplexityViolations = MathUtility.GetSum(veryHighCostComplexityViolations, highCostComplexityViolations); double?HighveryHighCostComplexityArtefactsPrev = MathUtility.GetSum(veryHighCostComplexityArtefactsPrev, highCostComplexityArtefactsPrev); double?HighveryHighCostComplexityViolationsPrev = MathUtility.GetSum(veryHighCostComplexityViolationsPrev, highCostComplexityViolationsPrev); #endregion SumMetric #region evolutionPercMetric double?criticalViolationEvolPerc = MathUtility.GetVariationPercent(criticalViolation, criticalViolationPrev); double?numCritPerFileEvolPerc = MathUtility.GetVariationPercent(numCritPerFile, numCritPerFilePrev); double?numCritPerKLOCEvolPerc = MathUtility.GetVariationPercent(numCritPerKLOC, numCritPerKLOCPrev); double?HighveryHighCostComplexityViolationsEvolPerc = MathUtility.GetVariationPercent(HighveryHighCostComplexityViolations, HighveryHighCostComplexityViolationsPrev); double?HighveryHighCostComplexityArtefactsEvolPerc = MathUtility.GetVariationPercent(HighveryHighCostComplexityArtefacts, HighveryHighCostComplexityArtefactsPrev); #endregion evolutionPercMetric var rowData = new List <string>() { Labels.Name , Labels.Current , Labels.Previous , Labels.EvolutionPercent , Labels.ViolationsCritical , (criticalViolation.HasValue) ? criticalViolation.Value.ToString(metricFormat): CastReporting.Domain.Constants.No_Value , (criticalViolationPrev.HasValue) ? criticalViolationPrev.Value.ToString(metricFormat) : CastReporting.Domain.Constants.No_Value , (criticalViolationEvolPerc.HasValue) ? TableBlock.FormatPercent(criticalViolationEvolPerc.Value): CastReporting.Domain.Constants.No_Value , " " + Labels.PerFile , numCritPerFileIfNegative , numCritPerFilePrevIfNegative , (numCritPerFileEvolPerc.HasValue) ? TableBlock.FormatPercent(numCritPerFileEvolPerc.Value) : CastReporting.Domain.Constants.No_Value , " " + Labels.PerkLoC , (numCritPerKLOC.HasValue)? numCritPerKLOC.Value.ToString("N2") : CastReporting.Domain.Constants.No_Value , (numCritPerKLOCPrev.HasValue)? numCritPerKLOCPrev.Value.ToString("N2") : CastReporting.Domain.Constants.No_Value , (numCritPerKLOCEvolPerc.HasValue) ? TableBlock.FormatPercent(numCritPerKLOCEvolPerc.Value) : CastReporting.Domain.Constants.No_Value , Labels.ComplexObjects , HighveryHighCostComplexityArtefacts.HasValue ? HighveryHighCostComplexityArtefacts.Value.ToString(metricFormat): CastReporting.Domain.Constants.No_Value , HighveryHighCostComplexityArtefactsPrev.HasValue ? HighveryHighCostComplexityArtefactsPrev.Value.ToString(metricFormat) : CastReporting.Domain.Constants.No_Value , HighveryHighCostComplexityArtefactsEvolPerc.HasValue ? TableBlock.FormatPercent(HighveryHighCostComplexityArtefactsEvolPerc.Value) : CastReporting.Domain.Constants.No_Value , " " + Labels.WithViolations , HighveryHighCostComplexityViolations.HasValue ? HighveryHighCostComplexityViolations.Value.ToString(metricFormat): CastReporting.Domain.Constants.No_Value , HighveryHighCostComplexityViolationsPrev.HasValue ? HighveryHighCostComplexityViolationsPrev.Value.ToString(metricFormat) : CastReporting.Domain.Constants.No_Value , HighveryHighCostComplexityViolationsEvolPerc.HasValue ? TableBlock.FormatPercent(HighveryHighCostComplexityViolationsEvolPerc.Value) : CastReporting.Domain.Constants.No_Value }; resultTable = new TableDefinition { HasRowHeaders = true, HasColumnHeaders = false, NbRows = 6, NbColumns = 4, Data = rowData }; } return(resultTable); }
public override TableDefinition Content(ReportData reportData, Dictionary <string, string> options) { TableDefinition back = new TableDefinition(); List <string> rowData = new List <string>(); double? previousHttVal = null; if (null == reportData) { return(back); } #region Selected Snapshot double?selectedLowVal = CastComplexityUtility.GetCostComplexityGrade(reportData.CurrentSnapshot, Constants.QualityDistribution.CostComplexityDistribution.GetHashCode(), Constants.CostComplexity.CostComplexityArtifacts_Low.GetHashCode()); double?selectedAveVal = CastComplexityUtility.GetCostComplexityGrade(reportData.CurrentSnapshot, Constants.QualityDistribution.CostComplexityDistribution.GetHashCode(), Constants.CostComplexity.CostComplexityArtifacts_Average.GetHashCode()); double?selectedHigVal = CastComplexityUtility.GetCostComplexityGrade(reportData.CurrentSnapshot, Constants.QualityDistribution.CostComplexityDistribution.GetHashCode(), Constants.CostComplexity.CostComplexityArtifacts_High.GetHashCode()); double?selectedVhiVal = CastComplexityUtility.GetCostComplexityGrade(reportData.CurrentSnapshot, Constants.QualityDistribution.CostComplexityDistribution.GetHashCode(), Constants.CostComplexity.CostComplexityArtifacts_VeryHigh.GetHashCode()); double?selectedTotal = (selectedLowVal.HasValue && selectedAveVal.HasValue && selectedHigVal.HasValue && selectedVhiVal.HasValue)?selectedLowVal.Value + selectedAveVal.Value + selectedHigVal.Value + selectedVhiVal.Value : (double?)null; double?selectedHttVal = (selectedHigVal.HasValue && selectedVhiVal.HasValue)?selectedHigVal.Value + selectedVhiVal.Value:(double?)null; #endregion Selected Snapshot #region Previous Snapshot if (reportData.PreviousSnapshot != null) { var previousHigVal = CastComplexityUtility.GetCostComplexityGrade(reportData.PreviousSnapshot, Constants.QualityDistribution.CostComplexityDistribution.GetHashCode(), Constants.CostComplexity.CostComplexityArtifacts_High.GetHashCode()); var previousVhiVal = CastComplexityUtility.GetCostComplexityGrade(reportData.PreviousSnapshot, Constants.QualityDistribution.CostComplexityDistribution.GetHashCode(), Constants.CostComplexity.CostComplexityArtifacts_VeryHigh.GetHashCode()); previousHttVal = previousHigVal.HasValue && previousVhiVal.HasValue ? previousHigVal.Value + previousVhiVal.Value : (double?)null; } #endregion Previous Snapshot #region Data int?variation = (selectedHttVal.HasValue && previousHttVal.HasValue) ? (int)(selectedHttVal - previousHttVal) : (int?)null; rowData.AddRange(new[] { Labels.Complexity, Labels.Current, Labels.Previous, Labels.Evol, Labels.TotalPercent }); rowData.AddRange(new[] { Labels.ComplexityHighAndVeryHigh , selectedHttVal?.ToString(MetricFormat) ?? Constants.No_Value , previousHttVal?.ToString(MetricFormat) ?? Constants.No_Value , variation.HasValue? FormatEvolution(variation.Value): Constants.No_Value , (selectedHttVal.HasValue && selectedTotal.HasValue && selectedTotal.Value > 0)? FormatPercent(selectedHttVal.Value / selectedTotal.Value, false): Constants.No_Value }); #endregion Data back = new TableDefinition { Data = rowData, HasRowHeaders = false, HasColumnHeaders = true, NbColumns = 5, NbRows = 2 }; return(back); }
protected override TableDefinition Content(ReportData reportData, Dictionary <string, string> options) { #region METHODS TableDefinition resultTable = null; if (reportData != null && reportData.CurrentSnapshot != null) { double?criticalViolation = MeasureUtility.GetSizingMeasure(reportData.CurrentSnapshot, Constants.SizingInformations.ViolationsToCriticalQualityRulesNumber); double?numCritPerFile = MeasureUtility.GetSizingMeasure(reportData.CurrentSnapshot, Constants.SizingInformations.ViolationsToCriticalQualityRulesPerFileNumber); double?numCritPerKLOC = MeasureUtility.GetSizingMeasure(reportData.CurrentSnapshot, Constants.SizingInformations.ViolationsToCriticalQualityRulesPerKLOCNumber); double?veryHighCostComplexityViolations = CastComplexityUtility.GetCostComplexityGrade(reportData.CurrentSnapshot, Constants. QualityDistribution.DistributionOfViolationsToCriticalDiagnosticBasedMetricsPerCostComplexity.GetHashCode(), Constants.ViolationsToCriticalDiagnosticBasedMetricsPerCostComplexity.ComplexityViolations_VeryHigh.GetHashCode()); double?highCostComplexityViolations = CastComplexityUtility.GetCostComplexityGrade(reportData.CurrentSnapshot, Constants.QualityDistribution.DistributionOfViolationsToCriticalDiagnosticBasedMetricsPerCostComplexity.GetHashCode(), Constants.ViolationsToCriticalDiagnosticBasedMetricsPerCostComplexity.ComplexityViolations_HighCost.GetHashCode()); double?veryHighCostComplexityArtefacts = CastComplexityUtility.GetCostComplexityGrade(reportData.CurrentSnapshot, Constants.QualityDistribution.CostComplexityDistribution.GetHashCode(), Constants.CostComplexity.CostComplexityArtifacts_VeryHigh.GetHashCode()); double?highCostComplexityArtefacts = CastComplexityUtility.GetCostComplexityGrade(reportData.CurrentSnapshot, Constants.QualityDistribution.CostComplexityDistribution.GetHashCode(), Constants.CostComplexity.CostComplexityArtifacts_High.GetHashCode()); double?nbComplexityArtefacts = MathUtility.GetSum(veryHighCostComplexityArtefacts, highCostComplexityArtefacts); double?nbComplexityArtefactsViolation = MathUtility.GetSum(veryHighCostComplexityViolations, highCostComplexityViolations); const string metricFormat = "N0"; const string metricFormatPrecision = "N2"; string numCritPerFileIfNegative = string.Empty; if (numCritPerFile == -1) { numCritPerFileIfNegative = "N/A"; } else { numCritPerFileIfNegative = (numCritPerFile.HasValue) ? numCritPerFile.Value.ToString(metricFormatPrecision) : Constants.No_Value; } var rowData = new List <string>() { Labels.Name , Labels.Value , Labels.ViolationsCritical , (criticalViolation.HasValue) ? criticalViolation.Value.ToString(metricFormat):Constants.No_Value , " " + Labels.PerFile , numCritPerFileIfNegative , " " + Labels.PerkLoC , (numCritPerKLOC.HasValue)? numCritPerKLOC.Value.ToString(metricFormatPrecision):Constants.No_Value , Labels.ComplexObjects , (nbComplexityArtefacts.HasValue)? nbComplexityArtefacts.Value.ToString(metricFormat):Constants.No_Value , " " + Labels.WithViolations , (nbComplexityArtefactsViolation.HasValue)? nbComplexityArtefactsViolation.Value.ToString(metricFormat):Constants.No_Value }; resultTable = new TableDefinition { HasRowHeaders = true, HasColumnHeaders = false, NbRows = 6, NbColumns = 2, Data = rowData }; } return(resultTable); }