本文整理汇总了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();
}
示例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;
}
示例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();
}
示例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;
}
示例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);
}
示例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);
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例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>();
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}