Example #1
0
        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);
        }
Example #2
0
        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);
        }
Example #3
0
        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);
        }
Example #4
0
        public override TableDefinition Content(ReportData reportData, Dictionary <string, string> options)
        {
            List <string> rowData             = new List <string>();
            bool          hasPreviousSnapshot = (null != reportData.PreviousSnapshot);

            double?previousLowVal = null;
            double?previousAveVal = null;
            double?previousHigVal = null;
            double?previousVhiVal = null;

            if (reportData.CurrentSnapshot != null)
            {
                #region Selected Snapshot

                var selectedName   = reportData.CurrentSnapshot.Annotation.Version;
                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());

                #endregion Selected Snapshot

                #region Previous Snapshot

                var 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(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
            }
            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)
        {
            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);
        }
        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.DistributionOfDefectsToCriticalDiagnosticBasedMetricsPerCostComplexity.GetHashCode(),
                                                                                                   Constants.DefectsToCriticalDiagnosticBasedMetricsPerCostComplexity.CostComplexityDefects_VeryHigh.GetHashCode());

            double?highCostComplexityViolations = CastComplexityUtility.GetCostComplexityGrade(reportData.CurrentSnapshot,
                                                                                               Constants.QualityDistribution.DistributionOfDefectsToCriticalDiagnosticBasedMetricsPerCostComplexity.GetHashCode(),
                                                                                               Constants.DefectsToCriticalDiagnosticBasedMetricsPerCostComplexity.CostComplexityDefects_High.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)
        {
            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);
        }
        /// <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);
        }
Example #10
0
        protected override TableDefinition Content(ReportData reportData, Dictionary <string, string> options)
        {
            TableDefinition back = new TableDefinition();

            bool   hasPreviousSnapshot = (null != reportData.PreviousSnapshot);
            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;


            if (null != reportData && null != reportData.CurrentSnapshot)
            {
                #region Selected Snapshot

                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());

                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
                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 string[] { Labels.Complexity, Labels.Current, Labels.Previous, Labels.Evol, Labels.EvolPercent, Labels.TotalPercent });

                const string noData = Constants.No_Data;

                rowData.AddRange(new string[]
                                 { Labels.ComplexityLow
                                   , selectedLowVal.HasValue ? selectedLowVal.Value.ToString("N0") : noData
                                   , previousLowVal.HasValue ? previousLowVal.Value.ToString("N0") : noData
                                   , (selectedLowVal.HasValue && previousLowVal.HasValue) ? TableBlock.FormatEvolution((Int32)(selectedLowVal.Value - previousLowVal.Value)) : noData
                                   , (selectedLowVal.HasValue && previousLowVal.HasValue && previousLowVal.Value != 0)? TableBlock.FormatPercent((selectedLowVal - previousLowVal) / previousLowVal)
                                                                                                      : noData
                                   , (selectedLowVal.HasValue && selectedTotal.HasValue && selectedTotal.Value > 0)?TableBlock.FormatPercent(selectedLowVal / selectedTotal, false): noData });

                rowData.AddRange(new string[]
                                 { Labels.ComplexityAverage
                                   , selectedAveVal.HasValue ? selectedAveVal.Value.ToString("N0"):noData
                                   , previousAveVal.HasValue ? previousAveVal.Value.ToString("N0") : noData
                                   , (selectedAveVal.HasValue && previousAveVal.HasValue) ? TableBlock.FormatEvolution((Int32)(selectedAveVal.Value - previousAveVal.Value)) : noData
                                   , (selectedAveVal.HasValue && previousAveVal.HasValue && previousAveVal.Value != 0)? TableBlock.FormatPercent((selectedAveVal - previousAveVal) / previousAveVal)
                                                                                                      : noData
                                   , (selectedAveVal.HasValue && selectedTotal.HasValue && selectedTotal.Value > 0)?TableBlock.FormatPercent(selectedAveVal / selectedTotal, false): noData });

                rowData.AddRange(new string[]
                                 { Labels.ComplexityHigh
                                   , selectedHigVal.HasValue ? selectedHigVal.Value.ToString("N0"): noData
                                   , previousHigVal.HasValue ? previousHigVal.Value.ToString("N0") : noData
                                   , (selectedHigVal.HasValue && previousHigVal.HasValue) ? TableBlock.FormatEvolution((Int32)(selectedHigVal.Value - previousHigVal.Value)) : noData
                                   , (selectedHigVal.HasValue && previousHigVal.HasValue && previousHigVal.Value != 0)? TableBlock.FormatPercent((selectedHigVal - previousHigVal) / previousHigVal)
                                                                                                      : noData
                                   , (selectedHigVal.HasValue && selectedTotal.HasValue && selectedTotal.Value > 0)?TableBlock.FormatPercent(selectedHigVal / selectedTotal, false): noData });

                rowData.AddRange(new string[]
                                 { Labels.ComplexityVeryHigh
                                   , selectedVhiVal.HasValue ? selectedVhiVal.Value.ToString("N0"): noData
                                   , previousVhiVal.HasValue ? previousVhiVal.Value.ToString("N0") : noData
                                   , previousVhiVal.HasValue ? TableBlock.FormatEvolution((Int32)(selectedVhiVal.Value - previousVhiVal.Value)): noData
                                   , (selectedVhiVal.HasValue && previousVhiVal.HasValue && previousVhiVal.Value != 0)? TableBlock.FormatPercent((selectedVhiVal - previousVhiVal) / previousVhiVal)
                                                                                                      : noData
                                   , (selectedVhiVal.HasValue && selectedTotal.HasValue && selectedTotal.Value > 0)?TableBlock.FormatPercent(selectedVhiVal / selectedTotal, false): noData });

                #endregion Data

                back = new TableDefinition
                {
                    HasRowHeaders    = false,
                    HasColumnHeaders = true,
                    Data             = rowData,
                    NbColumns        = 6,
                    NbRows           = 5
                };
            }

            return(back);
        }