Exemplo n.º 1
0
        public async System.Threading.Tasks.Task <ProjectQualityFactors> CalculateQualityFactors()
        {
            CodeQualityFactors    cqFactors = sqClient.CalculateCodeQuality();
            ProjectQualityFactors pFactors  = new ProjectQualityFactors();
            int openedIssues = await ghClient.CountOpenedIssuesAsync();

            int closedIssues = await ghClient.CountClosedIssuesAsync();

            int allLines            = sqClient.GetNumberOfAllLines();
            int numberOfMinorIssues = sqClient.GetNumberOfMinorIssues();

            Double maxNumberOfMinorIssues = Math.Round((double)allLines / 100);

            pFactors.CodeQualityRatio = 0.6;
            if ((openedIssues + closedIssues) > 0)
            {
                pFactors.KnownIssuesRatio = Math.Round(((double)openedIssues / (closedIssues + openedIssues)) * 70.0 * 0.4);
            }
            else
            {
                pFactors.KnownIssuesRatio = Math.Round(70.0 * 0.4);
            }

            pFactors.MinorIssuesRatio = numberOfMinorIssues > maxNumberOfMinorIssues?Math.Round(30.0 * 0.4) : Math.Round(((double)numberOfMinorIssues / maxNumberOfMinorIssues) * 30.0 * 0.4);

            pFactors.ProjectQuality = 100 - ((Math.Round(pFactors.CodeQualityRatio * (100 - cqFactors.CodeQuality))) + pFactors.KnownIssuesRatio + pFactors.MinorIssuesRatio);
            pFactors.CodeQuality    = cqFactors;

            return(pFactors);
        }
Exemplo n.º 2
0
        public CodeQualityFactors CalculateCodeQuality()
        {
            CodeQualityFactors cqFactors = new CodeQualityFactors();
            int    duplicatedLines       = GetNumberOfDuplicatedLines();
            int    allLines            = GetNumberOfAllLines();
            double?coverage            = GetPercentageCoverage();
            int    projectComplexity   = GetProjectComplexity();
            int    numberOfMajorIssues = GetNumberOfMajorIssues();

            double maxAllowedComplexity  = Math.Round((double)allLines / 10);
            double maxAllowedMajorIssues = Math.Round((double)allLines / 1000);

            double percentageUncoverage = coverage.HasValue ? coverage.Value : 100.0;
            double complexity           = projectComplexity > maxAllowedComplexity ? 1 : (double)projectComplexity / maxAllowedComplexity;
            double majorIssuesRatio     = numberOfMajorIssues > maxAllowedMajorIssues ? 1 : (double)numberOfMajorIssues / maxAllowedMajorIssues;

            cqFactors.ComplexityRatio      = Math.Round(10.0 * (double)complexity);
            cqFactors.DuplicatedLinesRatio = Math.Round(20.0 * ((double)duplicatedLines / allLines));
            cqFactors.MajorIssuesRatio     = Math.Round(50.0 * (double)majorIssuesRatio);
            cqFactors.TestUncoverageRatio  = Math.Round(20.0 * ((double)percentageUncoverage / 100));
            cqFactors.CodeQuality          = 100 - ((double)cqFactors.TestUncoverageRatio + cqFactors.DuplicatedLinesRatio + cqFactors.ComplexityRatio + cqFactors.MajorIssuesRatio);

            return(cqFactors);
        }