コード例 #1
0
 private static Task <FeatureEvidence> DuplicationCheck(CheckConfig checkConfig, int origCodeBaseCost, int origDuplicateCost, Feature duplicationCheck, string project)
 {
     return(Task.Run(() =>
     {
         var duplicationEvidence = RunDuplicationCheck(checkConfig, project, origCodeBaseCost, origDuplicateCost);
         duplicationEvidence.Feature = duplicationCheck;
         return duplicationEvidence;
     }));
 }
コード例 #2
0
        private static FeatureEvidence RunDuplicationCheck(CheckConfig checkConfig, string file, int origCodeBaseCost, int origDuplicateCost)
        {
            var dupFinder = new DupFinder(checkConfig.RunParameters.CMDToolsPath);

            var dupCheck = new DuplicationCheck(checkConfig.PathManager, dupFinder, file)
            {
                OrigCodeBaseCost  = origCodeBaseCost,
                OrigDuplicateCost = origDuplicateCost
            };

            dupCheck.PerformDuplicationCheck();

            return(dupCheck.DuplicationEvidence);
        }
コード例 #3
0
        private static FeatureEvidence RunCodeCoverage(CheckConfig checkConfig)
        {
            var codeCoverageEvidence = new FeatureEvidence {
                Feature = Feature.CodeCoverageCheck, HelperMessage = messages.CodeCoverageCheck
            };

            var dotCoverDir    = checkConfig.RunParameters.DotCoverDir;
            var fullReportPath = Path.GetTempFileName();

            var targetWorkingDir = Path.Combine(checkConfig.PathManager.ModifiedTestDirPath, testFolder);

            if (!Directory.Exists(targetWorkingDir))
            {
                codeCoverageEvidence.SetInconclusive(new SimpleEvidenceBuilder($"{testFolder} Directory Not Found"));
                return(codeCoverageEvidence);
            }

            var argument = CreateArgument("C:\\Program Files\\dotnet", targetWorkingDir, fullReportPath);

            new FeatureRunner().Execute(CreateProcessDetails(argument, processName, dotCoverDir));

            var report = ReadReport(fullReportPath);

            File.Delete(fullReportPath);

            try
            {
                var coverage = GetCodeCoverage(report);
                codeCoverageEvidence.FeatureRating = coverage / 100.0;
                var featureImplemented = coverage >= passPercentage;
                var evidence           = $"Code Coverage: {coverage}%";
                if (featureImplemented)
                {
                    codeCoverageEvidence.SetPassed(new SimpleEvidenceBuilder(evidence));
                }
                else
                {
                    codeCoverageEvidence.SetFailed(new SimpleEvidenceBuilder(evidence));
                }
            }
            catch (Exception e)
            {
                codeCoverageEvidence.SetInconclusive(new SimpleEvidenceBuilder(e.ToString()));
            }

            return(codeCoverageEvidence);
        }
コード例 #4
0
 public CheckManager(CheckConfig checkConfig)
 {
     this.checkConfig = checkConfig;
 }
コード例 #5
0
 public CodeCoverageCheck(CheckConfig checkConfig, Task <List <FeatureEvidence> > projectBuildTask)
 {
     this.checkConfig      = checkConfig;
     this.projectBuildTask = projectBuildTask;
 }
コード例 #6
0
 public DuplicationCheckRunner(CheckConfig checkConfig)
 {
     this.checkConfig = checkConfig;
 }