当前位置: 首页>>代码示例>>C#>>正文


C# Common.AnalysisConfig类代码示例

本文整理汇总了C#中SonarQube.Common.AnalysisConfig的典型用法代码示例。如果您正苦于以下问题:C# AnalysisConfig类的具体用法?C# AnalysisConfig怎么用?C# AnalysisConfig使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


AnalysisConfig类属于SonarQube.Common命名空间,在下文中一共展示了AnalysisConfig类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ProjectInfoReportBuilder

 private ProjectInfoReportBuilder(AnalysisConfig config, ProjectInfoAnalysisResult result, ILogger logger)
 {
     this.config = config;
     this.analysisResult = result;
     this.logger = logger;
     this.sb = new StringBuilder();
 }
开发者ID:nilleb,项目名称:sonar-msbuild-runner,代码行数:7,代码来源:ProjectInfoReportBuilder.cs

示例2: ExecuteJavaRunner

        /* for test purposes */
        public static bool ExecuteJavaRunner(AnalysisConfig config, IEnumerable<string> userCmdLineArguments, ILogger logger, string exeFileName, string propertiesFileName)
        {
            Debug.Assert(File.Exists(exeFileName), "The specified exe file does not exist: " + exeFileName);
            Debug.Assert(File.Exists(propertiesFileName), "The specified properties file does not exist: " + propertiesFileName);

            IgnoreSonarRunnerHome(logger);

            IEnumerable<string> allCmdLineArgs = GetAllCmdLineArgs(propertiesFileName, userCmdLineArguments, config);

            IDictionary<string, string> envVarsDictionary = GetAdditionalEnvVariables(logger);
            Debug.Assert(envVarsDictionary != null);

            logger.LogInfo(Resources.MSG_CallingSonarRunner);
            ProcessRunnerArguments runnerArgs = new ProcessRunnerArguments(exeFileName, logger)
            {
                CmdLineArgs = allCmdLineArgs,
                WorkingDirectory = Path.GetDirectoryName(exeFileName),
                EnvironmentVariables = envVarsDictionary
            };
            ProcessRunner runner = new ProcessRunner();

            bool success = runner.Execute(runnerArgs);

            success = success && !runner.ErrorsLogged;

            if (success)
            {
                logger.LogInfo(Resources.MSG_SonarRunnerCompleted);
            }
            else
            {
                logger.LogError(Resources.ERR_SonarRunnerExecutionFailed);
            }
            return success;
        }
开发者ID:nilleb,项目名称:sonar-msbuild-runner,代码行数:36,代码来源:SonarRunner.Wrapper.cs

示例3: GenerateReports

        /// <summary>
        /// Generates summary reports for LegacyTeamBuild and for Build Vnext
        /// </summary>
        public void GenerateReports(TeamBuildSettings settings, AnalysisConfig config, ProjectInfoAnalysisResult result, ILogger logger)
        {
            if (settings == null)
            {
                throw new ArgumentNullException("settings");
            }
            if (config == null)
            {
                throw new ArgumentNullException("config");
            }
            if (result == null)
            {
                throw new ArgumentNullException("result");
            }
            if (logger == null)
            {
                throw new ArgumentNullException("logger");
            }

            this.settings = settings;
            this.config = config;
            this.result = result;
            this.logger = logger;

            this.GenerateReports();
        }
开发者ID:nilleb,项目名称:sonar-msbuild-runner,代码行数:29,代码来源:SummaryReportBuilder.cs

示例4: GenerateFile

        public static AnalysisConfig GenerateFile(ProcessedArgs args, TeamBuildSettings settings, IDictionary<string, string> serverProperties, ILogger logger)
        {
            if (args == null)
            {
                throw new ArgumentNullException("args");
            }
            if (settings == null)
            {
                throw new ArgumentNullException("settings");
            }
            if (serverProperties == null)
            {
                throw new ArgumentNullException("serverProperties");
            }
            if (logger == null)
            {
                throw new ArgumentNullException("logger");
            }

            AnalysisConfig config = new AnalysisConfig();
            config.SonarProjectKey = args.ProjectKey;
            config.SonarProjectName = args.ProjectName;
            config.SonarProjectVersion = args.ProjectVersion;
            config.SonarQubeHostUrl = args.GetSetting(SonarProperties.HostUrl);

            config.SetBuildUri(settings.BuildUri);
            config.SetTfsUri(settings.TfsUri);
            config.SonarConfigDir = settings.SonarConfigDirectory;
            config.SonarOutputDir = settings.SonarOutputDirectory;
            config.SonarBinDir = settings.SonarBinDirectory;
            config.SonarRunnerWorkingDirectory = settings.SonarRunnerWorkingDirectory;

            // Add the server properties to the config
            config.ServerSettings = new AnalysisProperties();

            foreach (var property in serverProperties)
            {
                if (!IsSecuredServerProperty(property.Key))
                {
                    AddSetting(config.ServerSettings, property.Key, property.Value);
                }
            }

            // Add command line arguments
            config.LocalSettings = new AnalysisProperties();
            foreach (var property in args.LocalProperties.GetAllProperties())
            {
                AddSetting(config.LocalSettings, property.Id, property.Value);
            }

            // Set the pointer to the properties file
            if (args.PropertiesFileName != null)
            {
                config.SetSettingsFilePath(args.PropertiesFileName);
            }

            config.Save(settings.AnalysisConfigFilePath);

            return config;
        }
开发者ID:clintcparker,项目名称:sonar-msbuild-runner,代码行数:60,代码来源:AnalysisConfigGenerator.cs

示例5: SummaryReport_AllTypesOfProjects

        public void SummaryReport_AllTypesOfProjects()
        {
            // Arrange
            string hostUrl = "http://mySonarQube:9000";
            ProjectInfoAnalysisResult result = new ProjectInfoAnalysisResult() { RanToCompletion = true };
            AnalysisConfig config = new AnalysisConfig() { SonarProjectKey = "", SonarQubeHostUrl = hostUrl };

            AddProjectInfoToResult(result, ProjectInfoValidity.DuplicateGuid, count: 3);
            AddProjectInfoToResult(result, ProjectInfoValidity.ExcludeFlagSet, type: ProjectType.Product, count: 4);
            AddProjectInfoToResult(result, ProjectInfoValidity.ExcludeFlagSet, type: ProjectType.Test , count: 1);
            AddProjectInfoToResult(result, ProjectInfoValidity.InvalidGuid, type: ProjectType.Product, count: 7);
            AddProjectInfoToResult(result, ProjectInfoValidity.InvalidGuid, type: ProjectType.Test , count: 8);
            AddProjectInfoToResult(result, ProjectInfoValidity.NoFilesToAnalyze, count: 11);
            AddProjectInfoToResult(result, ProjectInfoValidity.Valid, type: ProjectType.Product, count: 13);
            AddProjectInfoToResult(result, ProjectInfoValidity.Valid, type: ProjectType.Test, count: 17);

            // Act
            var summaryReportData = SummaryReportBuilder.CreateSummaryData(config, result);

            // Assert
            VerifySummaryReportData(summaryReportData, result, hostUrl, config);
            VerifySummaryProjectCounts(
                summaryReportData,
                expectedExcludedProjects: 5, // ExcludeFlagSet
                expectedInvalidProjects: 18, // InvalidGuid + DuplicateGuid
                expectedSkippedProjects: 11, // No files to analyze
                expectedProductProjects: 13,
                expectedTestProjects: 17);
        }
开发者ID:nilleb,项目名称:sonar-msbuild-runner,代码行数:29,代码来源:SummaryReportBuilderTests.cs

示例6: GetAnalyzerSettings_ConfigExists_DataReturned

        public void GetAnalyzerSettings_ConfigExists_DataReturned()
        {
            // Arrange
            string testDir = TestUtils.CreateTestSpecificFolder(this.TestContext);
            GetAnalyzerSettings testSubject = new GetAnalyzerSettings();

            string[] expectedAnalyzers = new string[] { "c:\\analyzer1.DLL", "c:\\analyzer2.dll" };
            string[] expectedAdditionalFiles = new string[] { "c:\\add1.txt", "d:\\add2.txt" };

            // SONARMSBRU-216: non-assembly files should be filtered out
            List<string> filesInConfig = new List<string>(expectedAnalyzers);
            filesInConfig.Add("c:\\not_an_assembly.exe");
            filesInConfig.Add("c:\\not_an_assembly.zip");
            filesInConfig.Add("c:\\not_an_assembly.txt");
            filesInConfig.Add("c:\\not_an_assembly.dll.foo");
            filesInConfig.Add("c:\\not_an_assembly.winmd");

            AnalysisConfig config = new AnalysisConfig();
            config.AnalyzerSettings = new AnalyzerSettings();
            config.AnalyzerSettings.RuleSetFilePath = "f:\\yyy.ruleset";
            config.AnalyzerSettings.AnalyzerAssemblyPaths = filesInConfig;
            config.AnalyzerSettings.AdditionalFilePaths = expectedAdditionalFiles.ToList();
            string fullPath = Path.Combine(testDir, FileConstants.ConfigFileName);
            config.Save(fullPath);

            testSubject.AnalysisConfigDir = testDir;

            // Act
            ExecuteAndCheckSuccess(testSubject);

            // Assert
            Assert.AreEqual("f:\\yyy.ruleset", testSubject.RuleSetFilePath);
            CollectionAssert.AreEquivalent(expectedAnalyzers, testSubject.AnalyzerFilePaths);
            CollectionAssert.AreEquivalent(expectedAdditionalFiles, testSubject.AdditionalFiles);
        }
开发者ID:Godin,项目名称:sonar-msbuild-runner,代码行数:35,代码来源:GetAnalyzerSettingsTests.cs

示例7: GetAnalyzerSettings_ConfigExists_DataReturned

        public void GetAnalyzerSettings_ConfigExists_DataReturned()
        {
            // Arrange
            string testDir = TestUtils.CreateTestSpecificFolder(this.TestContext);
            GetAnalyzerSettings testSubject = new GetAnalyzerSettings();

            string[] expectedAnalyzers = new string[] { "c:\\analyzer1.dll", "c:\\analyzer2.dll" };
            string[] expectedAdditionalFiles = new string[] { "c:\\add1.txt", "d:\\add2.txt" };

            AnalysisConfig config = new AnalysisConfig();
            config.AnalyzerSettings = new AnalyzerSettings();
            config.AnalyzerSettings.RuleSetFilePath = "f:\\yyy.ruleset";
            config.AnalyzerSettings.AnalyzerAssemblyPaths = expectedAnalyzers.ToList();
            config.AnalyzerSettings.AdditionalFilePaths = expectedAdditionalFiles.ToList();
            string fullPath = Path.Combine(testDir, FileConstants.ConfigFileName);
            config.Save(fullPath);

            testSubject.AnalysisConfigDir = testDir;

            // Act
            ExecuteAndCheckSuccess(testSubject);

            // Assert
            Assert.AreEqual("f:\\yyy.ruleset", testSubject.RuleSetFilePath);
            CollectionAssert.AreEquivalent(expectedAnalyzers, testSubject.AnalyzerFilePaths);
            CollectionAssert.AreEquivalent(expectedAdditionalFiles, testSubject.AdditionalFiles);
        }
开发者ID:BrightLight,项目名称:sonar-msbuild-runner,代码行数:27,代码来源:GetAnalyzerSettingsTests.cs

示例8: Execute

        public ProjectInfoAnalysisResult Execute(AnalysisConfig config, IEnumerable<string> userCmdLineArguments, ILogger logger)
        {
            if (config == null)
            {
                throw new ArgumentNullException("config");
            }
            if (userCmdLineArguments == null)
            {
                throw new ArgumentNullException("userCmdLineArguments");
            }
            if (logger == null)
            {
                throw new ArgumentNullException("logger");
            }

            ProjectInfoAnalysisResult result = PropertiesFileGenerator.GenerateFile(config, logger);
            Debug.Assert(result != null, "Not expecting the file generator to return null");
            result.RanToCompletion = false;

            SonarProjectPropertiesValidator.Validate(
                config.SonarRunnerWorkingDirectory,
                result.Projects,
                onValid: () =>
                {
                    InternalExecute(config, userCmdLineArguments, logger, result);
                },
                onInvalid: (invalidFolders) =>
                {
                    // LOG error message
                    logger.LogError(Resources.ERR_ConflictingSonarProjectProperties, string.Join(", ", invalidFolders));
                });

            return result;
        }
开发者ID:BrightLight,项目名称:sonar-msbuild-runner,代码行数:34,代码来源:SonarRunner.Wrapper.cs

示例9: CreateSummaryData

        /* for test purposes */
        public static SummaryReportData CreateSummaryData(
            AnalysisConfig config,
            ProjectInfoAnalysisResult result)
        {
            if (config == null)
            {
                throw new ArgumentNullException("config");
            }
            if (result == null)
            {
                throw new ArgumentNullException("result");
            }

            SummaryReportData summaryData = new SummaryReportData();

            summaryData.SkippedProjects = GetProjectsByStatus(result, ProjectInfoValidity.NoFilesToAnalyze).Count();
            summaryData.InvalidProjects = GetProjectsByStatus(result, ProjectInfoValidity.InvalidGuid).Count();
            summaryData.InvalidProjects += GetProjectsByStatus(result, ProjectInfoValidity.DuplicateGuid).Count();

            summaryData.ExcludedProjects = GetProjectsByStatus(result, ProjectInfoValidity.ExcludeFlagSet).Count();
            IEnumerable<ProjectInfo> validProjects = GetProjectsByStatus(result, ProjectInfoValidity.Valid);
            summaryData.ProductProjects = validProjects.Count(p => p.ProjectType == ProjectType.Product);
            summaryData.TestProjects = validProjects.Count(p => p.ProjectType == ProjectType.Test);

            summaryData.Succeeded = result.RanToCompletion;

            summaryData.DashboardUrl = GetSonarDashboadUrl(config);
            summaryData.ProjectDescription = string.Format(System.Globalization.CultureInfo.CurrentCulture,
                Resources.Report_SonarQubeProjectDescription, config.SonarProjectName, config.SonarProjectKey, config.SonarProjectVersion);
            return summaryData;
        }
开发者ID:nilleb,项目名称:sonar-msbuild-runner,代码行数:32,代码来源:SummaryReportBuilder.cs

示例10: Execute

        public ProjectInfoAnalysisResult Execute(AnalysisConfig config, IEnumerable<string> userCmdLineArguments, ILogger logger)
        {
            Assert.IsFalse(this.methodCalled, "Runner should only be called once");
            this.methodCalled = true;
            this.SuppliedCommandLineArgs = userCmdLineArguments;

            return this.ValueToReturn;
        }
开发者ID:BrightLight,项目名称:sonar-msbuild-runner,代码行数:8,代码来源:MockSonarRunner.cs

示例11: PropertiesWriter

        public PropertiesWriter(AnalysisConfig config)
        {
            if (config == null)
            {
                throw new ArgumentNullException("config");
            }

            this.config = config;
            this.sb = new StringBuilder();
            this.projects = new List<ProjectInfo>();
        }
开发者ID:BrightLight,项目名称:sonar-msbuild-runner,代码行数:11,代码来源:PropertiesWriter.cs

示例12: GenerateFile

        public /* for test */ static ProjectInfoAnalysisResult GenerateFile(AnalysisConfig config, ILogger logger, IRoslynV1SarifFixer fixer)
        {
            if (config == null)
            {
                throw new ArgumentNullException("config");
            }
            if (logger == null)
            {
                throw new ArgumentNullException("logger");
            }

            string fileName = Path.Combine(config.SonarOutputDir, ProjectPropertiesFileName);
            logger.LogDebug(Resources.MSG_GeneratingProjectProperties, fileName);

            IEnumerable<ProjectInfo> projects = ProjectLoader.LoadFrom(config.SonarOutputDir);
            if (projects == null || !projects.Any())
            {
                logger.LogError(Resources.ERR_NoProjectInfoFilesFound);
                return new ProjectInfoAnalysisResult();
            }

            FixSarifReport(logger, projects, fixer);

            PropertiesWriter writer = new PropertiesWriter(config);

            ProjectInfoAnalysisResult result = ProcessProjectInfoFiles(projects, writer, logger);

            IEnumerable<ProjectInfo> validProjects = result.GetProjectsByStatus(ProjectInfoValidity.Valid);

            if (validProjects.Any())
            {
                // Handle global settings
                AnalysisProperties properties = GetAnalysisPropertiesToWrite(config, logger);
                writer.WriteGlobalSettings(properties);

                string contents = writer.Flush();

                result.FullPropertiesFilePath = fileName;
                File.WriteAllText(result.FullPropertiesFilePath, contents, Encoding.ASCII);
            }
            else
            {
                // if the user tries to build multiple configurations at once there will be duplicate projects
                if (result.GetProjectsByStatus(ProjectInfoValidity.DuplicateGuid).Any())
                {
                    logger.LogError(Resources.ERR_NoValidButDuplicateProjects);
                }
                else
                {
                    logger.LogError(Resources.ERR_NoValidProjectInfoFiles);
                }
            }
            return result;
        }
开发者ID:BrightLight,项目名称:sonar-msbuild-runner,代码行数:54,代码来源:PropertiesFileGenerator.cs

示例13: Initialise

        public bool Initialise(AnalysisConfig config, TeamBuildSettings settings, ILogger logger)
        {
            if (settings == null)
            {
                throw new ArgumentNullException("settings");
            }

            this.TryCreateCoverageReportProcessor(settings);

            this.initialisedSuccesfully = (this.processor != null && this.processor.Initialise(config, settings, logger));
            return this.initialisedSuccesfully;
        }
开发者ID:nilleb,项目名称:sonar-msbuild-runner,代码行数:12,代码来源:CoverageReportProcessor.cs

示例14: SonarRunner_StandardAdditionalArgumentsPassed

        public void SonarRunner_StandardAdditionalArgumentsPassed()
        {
            // Arrange
            TestLogger logger = new TestLogger();
            string exePath = CreateDummarySonarRunnerBatchFile();
            string propertiesFilePath = CreateDummySonarRunnerPropertiesFile();
            AnalysisConfig config = new AnalysisConfig() { SonarRunnerWorkingDirectory = this.TestContext.DeploymentDirectory };

            // Act
            bool success = SonarRunnerWrapper.ExecuteJavaRunner(config, Enumerable.Empty<string>(), logger, exePath, propertiesFilePath);

            // Assert
            VerifyProcessRunOutcome(logger, this.TestContext.DeploymentDirectory, success, true);
        }
开发者ID:BrightLight,项目名称:sonar-msbuild-runner,代码行数:14,代码来源:SonarRunnerWrapperTests.cs

示例15: TryGetRegularExpression

        private string TryGetRegularExpression(AnalysisConfig config)
        {
            Debug.Assert(config != null, "Not expecting the supplied config to be null");

            string regEx;
            config.GetAnalysisSettings(true).TryGetValue(TestRegExSettingId, out regEx);
            
            if (!string.IsNullOrWhiteSpace(regEx))
            {
                this.Log.LogMessage(MessageImportance.Low, Resources.IsTest_UsingRegExFromConfig, regEx);
            }

            return regEx;
        }
开发者ID:BrightLight,项目名称:sonar-msbuild-runner,代码行数:14,代码来源:IsTestFileByName.cs


注:本文中的SonarQube.Common.AnalysisConfig类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。