Example #1
0
        public override TableDefinition Content(ReportData reportData, Dictionary <string, string> options)
        {
            int count = 0;

            List <string> rowData = new List <string>();

            rowData.AddRange(new[] {
                Labels.TQI,
                Labels.ViolationsCritical + "/" + Labels.kLoC,
                Labels.AutomatedFP,
                Labels.Application
            });

            #region Fetch SnapshotsPF

            if (reportData?.Applications != null && reportData.Snapshots != null)
            {
                Application[] _allApps = reportData.Applications;
                foreach (Application _app in _allApps)
                {
                    Snapshot _snapshot = _app.Snapshots.OrderByDescending(_ => _.Annotation.Date.DateSnapShot).First();

                    BusinessCriteriaDTO currSnapshotBisCriDTO = BusinessCriteriaUtility.GetBusinessCriteriaGradesSnapshot(_snapshot, false);
                    double?strCurrentTQI   = currSnapshotBisCriDTO.TQI ?? 0;
                    double?_numCritPerKloc = MeasureUtility.GetSizingMeasure(_snapshot, Constants.SizingInformations.ViolationsToCriticalQualityRulesPerKLOCNumber);
                    double?result          = MeasureUtility.GetAutomatedIFPUGFunction(_snapshot);

                    rowData.Add(strCurrentTQI.GetValueOrDefault().ToString("N2"));
                    rowData.Add(_numCritPerKloc.GetValueOrDefault().ToString("N2"));
                    rowData.Add(result.GetValueOrDefault().ToString(CultureInfo.CurrentCulture));
                    rowData.Add(_app.Name);

                    count++;
                }

                if (reportData.Applications.Length == 1)
                {
                    rowData.AddRange(new[] { "0", "0", "0", "" });

                    count++;
                }
            }
            #endregion Fetch SnapshotsPF

            TableDefinition resultTable = new TableDefinition
            {
                HasRowHeaders    = false,
                HasColumnHeaders = true,
                NbRows           = count + 1,
                NbColumns        = 4,
                Data             = rowData
            };
            return(resultTable);
        }
Example #2
0
        protected override TableDefinition Content(ReportData reportData, Dictionary <string, string> options)
        {
            #region Required Options
            string moduleIdstr = (options != null && options.ContainsKey("M") ? options["M"] : string.Empty);
            int    moduleId;
            if (string.IsNullOrWhiteSpace(moduleIdstr) || !Int32.TryParse(moduleIdstr, out moduleId))
            {
                moduleId = -1;
            }

            #endregion Required Options

            List <String> rowData = new List <String>();
            rowData.AddRange(new string[] { Labels.TechnicalDebt + " (" + reportData.CurrencySymbol + ")", Labels.TQI, Labels.Size });

            if (reportData != null && reportData.CurrentSnapshot != null)
            {
                double?TQIValue      = 0;
                double?TechDebtValue = 0;
                double?COLValue      = 0;

                if (moduleId > 0)
                {
                    TQIValue      = BusinessCriteriaUtility.GetBusinessCriteriaModuleGrade(reportData.CurrentSnapshot, moduleId, Constants.BusinessCriteria.TechnicalQualityIndex, true);
                    TechDebtValue = MeasureUtility.GetModuleMeasureGrade(reportData.CurrentSnapshot, moduleId, Constants.SizingInformations.TechnicalDebt);
                    COLValue      = MeasureUtility.GetModuleMeasureGrade(reportData.CurrentSnapshot, moduleId, Constants.SizingInformations.CodeLineNumber);
                }
                else
                {
                    TQIValue      = BusinessCriteriaUtility.GetSnapshotBusinessCriteriaGrade(reportData.CurrentSnapshot, Constants.BusinessCriteria.TechnicalQualityIndex, true);
                    TechDebtValue = MeasureUtility.GetSizingMeasure(reportData.CurrentSnapshot, Constants.SizingInformations.TechnicalDebt);
                    COLValue      = MeasureUtility.GetSizingMeasure(reportData.CurrentSnapshot, Constants.SizingInformations.CodeLineNumber);
                }

                rowData.Add(TQIValue.GetValueOrDefault().ToString());
                rowData.Add(TechDebtValue.GetValueOrDefault().ToString());
                rowData.Add(COLValue.GetValueOrDefault().ToString());
            }

            TableDefinition resultTable = new TableDefinition
            {
                HasRowHeaders    = false,
                HasColumnHeaders = true,
                NbRows           = 2,
                NbColumns        = 3,
                Data             = rowData
            };
            return(resultTable);
        }
        protected override TableDefinition Content(ReportData reportData, Dictionary <string, string> options)
        {
            int count = 0;

            List <String> rowData = new List <String>();

            //var rowData = new List<String>();
            rowData.AddRange(new string[] {
                Labels.TQI,
                Labels.ViolationsCritical + "/" + Labels.kLoC,
                Labels.AutomatedFP,
                Labels.Application
            });


            #region Fetch SnapshotsPF

            if (reportData != null && reportData.Applications != null && reportData.snapshots != null)
            {
                Application[] AllApps = reportData.Applications;
                for (int j = 0; j < AllApps.Count(); j++)
                {
                    Application App = AllApps[j];

                    int nbSnapshotsEachApp = App.Snapshots.Count();
                    if (nbSnapshotsEachApp > 0)
                    {
                        foreach (Snapshot snapshot in App.Snapshots.OrderByDescending(_ => _.Annotation.Date.DateSnapShot))
                        {
                            Snapshot[] BuiltSnapshots = reportData.snapshots;

                            foreach (Snapshot BuiltSnapshot in BuiltSnapshots)
                            {
                                if (snapshot == BuiltSnapshot)
                                {
                                    string currSnapshotLabel = SnapshotUtility.GetSnapshotVersionNumber(BuiltSnapshot);
                                    BusinessCriteriaDTO currSnapshotBisCriDTO = BusinessCriteriaUtility.GetBusinessCriteriaGradesSnapshot(BuiltSnapshot, false);
                                    double?strCurrentTQI = currSnapshotBisCriDTO.TQI.HasValue ? MathUtility.GetRound(currSnapshotBisCriDTO.TQI.Value) : 0;

                                    double?numCritPerKLOC = MeasureUtility.GetSizingMeasure(BuiltSnapshot, Constants.SizingInformations.ViolationsToCriticalQualityRulesPerKLOCNumber);

                                    //double? result = MeasureUtility.GetAddedFunctionPoint(BuiltSnapshot) + MeasureUtility.GetModifiedFunctionPoint(BuiltSnapshot) + MeasureUtility.GetDeletedFunctionPoint(BuiltSnapshot);
                                    double?result = MeasureUtility.GetAfpMetricDF(BuiltSnapshot) + MeasureUtility.GetAfpMetricTF(BuiltSnapshot);

                                    rowData.AddRange(new string[] {
                                        strCurrentTQI.GetValueOrDefault().ToString(),
                                        numCritPerKLOC.GetValueOrDefault().ToString(),
                                        result.GetValueOrDefault().ToString(),
                                        App.Name.ToString()
                                    });

                                    count++;
                                }
                            }

                            break;
                        }
                    }
                }
                if (reportData.Applications.Count() == 1)
                {
                    rowData.AddRange(new string[] { "0", "0", "0", "" });

                    count++;
                }
            }
            #endregion Fetch SnapshotsPF



            TableDefinition resultTable = new TableDefinition
            {
                HasRowHeaders    = false,
                HasColumnHeaders = true,
                NbRows           = count + 1,
                NbColumns        = 4,
                Data             = rowData
            };
            return(resultTable);
        }
        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);
        }
        public override string Content(ReportData reportData, Dictionary <string, string> options)
        {
            string _metricFormat = options.GetOption("FORMAT", "N2");
            string _params       = options.GetOption("PARAMS", string.Empty);
            string _expr         = options.GetOption("EXPR", string.Empty);
            string _aggregator   = options.GetOption("AGGREGATOR", "AVERAGE");

            string[] lstParams = _params.Split(' ');

            if (string.IsNullOrEmpty(_params))
            {
                return(Labels.NoData);
            }
            if (reportData?.Applications == null)
            {
                return(Labels.NoData);
            }
            Application[] _allApps  = reportData.Applications;
            string[]      strValues = new string[_allApps.Length];

            for (int k = 0; k < _allApps.Length; k++)
            {
                Application _app        = _allApps[k];
                string      _appExpr    = _expr;
                Snapshot    currentSnap = _app.Snapshots.OrderByDescending(_ => _.Annotation.Date.DateSnapShot).First();
                if (currentSnap == null)
                {
                    continue;
                }
                for (int i = 0; i < lstParams.Length; i += 2)
                {
                    string param = lstParams[i + 1];
                    double?paramValue;

                    switch (lstParams[i])
                    {
                    case "SZ":
                        int sizingId = int.Parse(options.GetOption(lstParams[i + 1], "0"));
                        if (sizingId == 0)
                        {
                            paramValue = null;
                            break;
                        }
                        paramValue = MeasureUtility.GetSizingMeasure(currentSnap, sizingId);
                        break;

                    case "QR":
                        int qrId = int.Parse(options.GetOption(lstParams[i + 1], "0"));
                        if (qrId == 0)
                        {
                            paramValue = null;
                            break;
                        }
                        paramValue = BusinessCriteriaUtility.GetMetricValue(currentSnap, qrId);
                        break;

                    case "BF":
                        string bfId = options.GetOption(lstParams[i + 1], string.Empty);
                        if (string.IsNullOrEmpty(bfId))
                        {
                            paramValue = null;
                            break;
                        }
                        var bfValue = reportData.SnapshotExplorer.GetBackgroundFacts(currentSnap.Href, bfId).FirstOrDefault();
                        if (bfValue != null && bfValue.ApplicationResults.Any())
                        {
                            paramValue = bfValue.ApplicationResults[0].DetailResult.Value;
                        }
                        else
                        {
                            paramValue = null;
                        }
                        break;

                    default:
                        throw new ArgumentOutOfRangeException();
                    }
                    if (paramValue != null)
                    {
                        _appExpr = _appExpr.Replace(param, paramValue.ToString());
                    }
                }
                DataTable dt = new DataTable();
                string    value;
                try
                {
                    value = double.Parse(dt.Compute(_appExpr, "").ToString()).ToString(_metricFormat);
                }
                catch (EvaluateException)
                {
                    value = null;
                }

                if (!string.IsNullOrEmpty(value))
                {
                    strValues[k] = value;
                }
                else
                {
                    strValues[k] = Labels.NoData;
                }
            }


            if (_aggregator == "SUM")
            {
                double sumValues = strValues.Where(val => val != Labels.NoData).Sum(val => double.Parse(val));
                return(sumValues.ToString(_metricFormat));
            }
            else
            {
                double sumValues = 0;
                int    nbValues  = 0;
                foreach (string val in strValues)
                {
                    if (val == Labels.NoData)
                    {
                        continue;
                    }
                    nbValues++;
                    sumValues += double.Parse(val);
                }
                if (nbValues == 0)
                {
                    return(Labels.NoData);
                }
                var avgValues = sumValues / nbValues;
                return(avgValues.ToString(_metricFormat));
            }
        }
        public override string Content(ReportData reportData, Dictionary <string, string> options)
        {
            string _metricFormat = options.GetOption("FORMAT", "N2");
            string _params       = options.GetOption("PARAMS", string.Empty);
            string _expr         = options.GetOption("EXPR", string.Empty);
            string _snapshot     = options.GetOption("SNAPSHOT", "CURRENT");

            string[] lstParams     = _params.Split(' ');
            string   strParameters = string.Empty;

            object[] objValues = new object[lstParams.Length / 2];

            if (reportData?.CurrentSnapshot == null)
            {
                return(Labels.NoData);
            }
            if (string.IsNullOrEmpty(_params))
            {
                return(Labels.NoData);
            }
            int j = 0;

            for (int i = 0; i < lstParams.Length; i += 2)
            {
                if (i == 0)
                {
                    strParameters = "double " + lstParams[i + 1];
                }
                else
                {
                    strParameters = strParameters + ", double " + lstParams[i + 1];
                }

                switch (lstParams[i])
                {
                case "SZ":
                    int sizingId = int.Parse(options.GetOption(lstParams[i + 1], "0"));
                    if (sizingId == 0)
                    {
                        return(Labels.NoData);
                    }
                    double?sizingValue;
                    if (_snapshot.Equals("PREVIOUS") && null != reportData.PreviousSnapshot)
                    {
                        sizingValue = MeasureUtility.GetSizingMeasure(reportData.PreviousSnapshot, sizingId);
                    }
                    else
                    {
                        sizingValue = MeasureUtility.GetSizingMeasure(reportData.CurrentSnapshot, sizingId);
                    }
                    objValues[j] = sizingValue;
                    j++;
                    break;

                case "QR":
                    int qrId = int.Parse(options.GetOption(lstParams[i + 1], "0"));
                    if (qrId == 0)
                    {
                        return(Labels.NoData);
                    }
                    double?qrGrade;
                    if (_snapshot.Equals("PREVIOUS") && null != reportData.PreviousSnapshot)
                    {
                        qrGrade = BusinessCriteriaUtility.GetMetricValue(reportData.PreviousSnapshot, qrId);
                    }
                    else
                    {
                        qrGrade = BusinessCriteriaUtility.GetMetricValue(reportData.CurrentSnapshot, qrId);
                    }
                    objValues[j] = qrGrade;
                    j++;
                    break;

                case "BF":
                    string bfId = options.GetOption(lstParams[i + 1], string.Empty);
                    if (string.IsNullOrEmpty(bfId))
                    {
                        return(Labels.NoData);
                    }
                    Result bfValue;
                    if (_snapshot.Equals("PREVIOUS") && null != reportData.PreviousSnapshot)
                    {
                        bfValue = reportData.SnapshotExplorer.GetBackgroundFacts(reportData.PreviousSnapshot.Href, bfId).FirstOrDefault();
                    }
                    else
                    {
                        bfValue = reportData.SnapshotExplorer.GetBackgroundFacts(reportData.CurrentSnapshot.Href, bfId).FirstOrDefault();
                    }
                    if (bfValue != null && bfValue.ApplicationResults.Any())
                    {
                        objValues[j] = bfValue.ApplicationResults[0].DetailResult.Value;
                    }
                    else
                    {
                        return(Labels.NoData);
                    }
                    j++;
                    break;

                default:
                    return(Labels.NoData);
                }
            }

            string value = ExpressionEvaluator.Eval(strParameters, _expr, objValues, _metricFormat);

            return(value);
        }
        public override string Content(ReportData reportData, Dictionary <string, string> options)
        {
            string _metricFormat = options.GetOption("FORMAT", "N2");
            string _params       = options.GetOption("PARAMS", string.Empty);
            string _expr         = options.GetOption("EXPR", string.Empty);
            string _snapshot     = options.GetOption("SNAPSHOT", "CURRENT");

            string[] lstParams = _params.Split(' ');

            if (reportData?.CurrentSnapshot == null)
            {
                return(Labels.NoData);
            }
            if (string.IsNullOrEmpty(_params))
            {
                return(Labels.NoData);
            }
            for (int i = 0; i < lstParams.Length; i += 2)
            {
                string param = lstParams[i + 1];
                double?paramValue;

                switch (lstParams[i])
                {
                case "SZ":
                    int sizingId = int.Parse(options.GetOption(lstParams[i + 1], "0"));
                    if (sizingId == 0)
                    {
                        return(Labels.NoData);
                    }
                    double?sizingValue;
                    if (_snapshot.Equals("PREVIOUS") && null != reportData.PreviousSnapshot)
                    {
                        sizingValue = MeasureUtility.GetSizingMeasure(reportData.PreviousSnapshot, sizingId);
                    }
                    else
                    {
                        sizingValue = MeasureUtility.GetSizingMeasure(reportData.CurrentSnapshot, sizingId);
                    }
                    paramValue = sizingValue;
                    break;

                case "QR":
                    int qrId = int.Parse(options.GetOption(lstParams[i + 1], "0"));
                    if (qrId == 0)
                    {
                        return(Labels.NoData);
                    }
                    double?qrGrade;
                    if (_snapshot.Equals("PREVIOUS") && null != reportData.PreviousSnapshot)
                    {
                        qrGrade = BusinessCriteriaUtility.GetMetricValue(reportData.PreviousSnapshot, qrId);
                    }
                    else
                    {
                        qrGrade = BusinessCriteriaUtility.GetMetricValue(reportData.CurrentSnapshot, qrId);
                    }
                    paramValue = qrGrade;
                    break;

                case "BF":
                    string bfId = options.GetOption(lstParams[i + 1], string.Empty);
                    if (string.IsNullOrEmpty(bfId))
                    {
                        return(Labels.NoData);
                    }
                    Result bfValue;
                    if (_snapshot.Equals("PREVIOUS") && null != reportData.PreviousSnapshot)
                    {
                        bfValue = reportData.SnapshotExplorer.GetBackgroundFacts(reportData.PreviousSnapshot.Href, bfId).FirstOrDefault();
                    }
                    else
                    {
                        bfValue = reportData.SnapshotExplorer.GetBackgroundFacts(reportData.CurrentSnapshot.Href, bfId).FirstOrDefault();
                    }
                    if (bfValue != null && bfValue.ApplicationResults.Any())
                    {
                        paramValue = bfValue.ApplicationResults[0].DetailResult.Value;
                    }
                    else
                    {
                        return(Labels.NoData);
                    }
                    break;

                default:
                    return(Labels.NoData);
                }
                if (paramValue != null)
                {
                    _expr = _expr.Replace(param, paramValue.ToString());
                }
            }
            DataTable dt = new DataTable();

            return(double.Parse(dt.Compute(_expr, "").ToString()).ToString(_metricFormat));
        }
        public override string Content(ReportData reportData, Dictionary <string, string> options)
        {
            string _metricFormat = options.GetOption("FORMAT", "N2");
            string _params       = options.GetOption("PARAMS", string.Empty);
            string _expr         = options.GetOption("EXPR", string.Empty);
            string _aggregator   = options.GetOption("AGGREGATOR", "AVERAGE");

            string[] lstParams     = _params.Split(' ');
            string   strParameters = string.Empty;

            object[] objValues = new object[lstParams.Length / 2];

            if (string.IsNullOrEmpty(_params))
            {
                return(Labels.NoData);
            }
            if (reportData?.Applications == null)
            {
                return(Labels.NoData);
            }
            Application[] _allApps  = reportData.Applications;
            string[]      strValues = new string[_allApps.Length];

            for (int k = 0; k < _allApps.Length; k++)
            {
                Application _app = _allApps[k];

                Snapshot currentSnap = _app.Snapshots.OrderByDescending(_ => _.Annotation.Date.DateSnapShot).First();
                if (currentSnap == null)
                {
                    continue;
                }
                int j = 0;
                for (int i = 0; i < lstParams.Length; i += 2)
                {
                    if (i == 0)
                    {
                        strParameters = "double " + lstParams[i + 1];
                    }
                    else
                    {
                        strParameters = strParameters + ", double " + lstParams[i + 1];
                    }

                    switch (lstParams[i])
                    {
                    case "SZ":
                        int sizingId = int.Parse(options.GetOption(lstParams[i + 1], "0"));
                        if (sizingId == 0)
                        {
                            objValues[j] = Labels.NoData;
                            break;
                        }
                        var sizingValue = MeasureUtility.GetSizingMeasure(currentSnap, sizingId);
                        if (sizingValue != null)
                        {
                            objValues[j] = sizingValue;
                        }
                        else
                        {
                            objValues[j] = Labels.NoData;
                        }
                        j++;
                        break;

                    case "QR":
                        int qrId = int.Parse(options.GetOption(lstParams[i + 1], "0"));
                        if (qrId == 0)
                        {
                            objValues[j] = Labels.NoData;
                            break;
                        }
                        var qrGrade = BusinessCriteriaUtility.GetMetricValue(currentSnap, qrId);
                        if (qrGrade != null)
                        {
                            objValues[j] = qrGrade;
                        }
                        else
                        {
                            objValues[j] = Labels.NoData;
                        }
                        j++;
                        break;

                    case "BF":
                        string bfId = options.GetOption(lstParams[i + 1], string.Empty);
                        if (string.IsNullOrEmpty(bfId))
                        {
                            objValues[j] = Labels.NoData;
                            break;
                        }
                        var bfValue = reportData.SnapshotExplorer.GetBackgroundFacts(currentSnap.Href, bfId).FirstOrDefault();
                        if (bfValue != null && bfValue.ApplicationResults.Any())
                        {
                            objValues[j] = bfValue.ApplicationResults[0].DetailResult.Value;
                        }
                        else
                        {
                            objValues[j] = Labels.NoData;
                        }
                        j++;
                        break;

                    default:
                        throw new ArgumentOutOfRangeException();
                    }
                }
                string value = ExpressionEvaluator.Eval(strParameters, _expr, objValues, string.Empty);
                if (!value.Contains("Error"))
                {
                    strValues[k] = value;
                }
                else
                {
                    strValues[k] = Labels.NoData;
                }
            }


            if (_aggregator == "SUM")
            {
                double sumValues = strValues.Where(val => val != Labels.NoData).Sum(val => double.Parse(val));
                return(sumValues.ToString(_metricFormat));
            }
            else
            {
                double sumValues = 0;
                int    nbValues  = 0;
                foreach (string val in strValues)
                {
                    if (val == Labels.NoData)
                    {
                        continue;
                    }
                    nbValues++;
                    sumValues += double.Parse(val);
                }
                if (nbValues == 0)
                {
                    return(Labels.NoData);
                }
                var avgValues = sumValues / nbValues;
                return(avgValues.ToString(_metricFormat));
            }
        }
Example #10
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 #11
0
        public override string Content(ReportData reportData, Dictionary <string, string> options)
        {
            int    metricId   = options.GetIntOption("ID");
            int    metricSzId = options.GetIntOption("SZID");
            int    metricBfId = options.GetIntOption("BFID");
            string _format    = options.GetOption("FORMAT", "N0");
            string _snapshot  = options.GetOption("SNAPSHOT", "CURRENT");

            if (reportData?.CurrentSnapshot != null && metricId != 0)
            {
                if (_snapshot == "PREVIOUS")
                {
                    if (reportData.PreviousSnapshot == null)
                    {
                        return(Constants.No_Value);
                    }
                    double?result = BusinessCriteriaUtility.GetMetricValue(reportData.PreviousSnapshot, metricId);
                    return(result?.ToString("N2") ?? Constants.No_Value);
                }
                else
                {
                    double?result = BusinessCriteriaUtility.GetMetricValue(reportData.CurrentSnapshot, metricId);
                    return(result?.ToString("N2") ?? Constants.No_Value);
                }
            }
            if (reportData?.CurrentSnapshot != null && metricSzId != 0)
            {
                if (_snapshot == "PREVIOUS")
                {
                    if (reportData.PreviousSnapshot == null)
                    {
                        return(Constants.No_Value);
                    }
                    double?result = MeasureUtility.GetSizingMeasure(reportData.PreviousSnapshot, metricSzId);
                    return(result?.ToString(_format) ?? Constants.No_Value);
                }
                else
                {
                    double?result = MeasureUtility.GetSizingMeasure(reportData.CurrentSnapshot, metricSzId);
                    return(result?.ToString(_format) ?? Constants.No_Value);
                }
            }
            // ReSharper disable once InvertIf
            if (reportData?.CurrentSnapshot != null && metricBfId != 0)
            {
                if (_snapshot == "PREVIOUS")
                {
                    if (reportData.PreviousSnapshot == null)
                    {
                        return(Constants.No_Value);
                    }
                    Result bfValue = reportData.SnapshotExplorer.GetBackgroundFacts(reportData.PreviousSnapshot.Href, metricBfId.ToString()).FirstOrDefault();
                    if (bfValue == null || !bfValue.ApplicationResults.Any())
                    {
                        return(Constants.No_Value);
                    }
                    double?result = bfValue.ApplicationResults[0].DetailResult?.Value;
                    return(result?.ToString(_format) ?? Constants.No_Value);
                }
                else
                {
                    Result bfValue = reportData.SnapshotExplorer.GetBackgroundFacts(reportData.CurrentSnapshot.Href, metricBfId.ToString()).FirstOrDefault();
                    if (bfValue == null || !bfValue.ApplicationResults.Any())
                    {
                        return(Constants.No_Value);
                    }
                    double?result = bfValue.ApplicationResults[0].DetailResult?.Value;
                    return(result?.ToString(_format) ?? Constants.No_Value);
                }
            }

            return(Constants.No_Value);
        }
        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);
        }