From 3b73e8cd83aeb5cfb73b069ee882578b041d794a Mon Sep 17 00:00:00 2001 From: Gregory Paidis Date: Fri, 6 Sep 2024 12:10:01 +0200 Subject: [PATCH] Multi-language support: Re-enable sonar.sources and sonar.tests --- src/SonarScanner.MSBuild.PreProcessor/ProcessedArgs.cs | 6 ------ src/SonarScanner.MSBuild.Shim/AdditionalFilesService.cs | 6 +++++- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/SonarScanner.MSBuild.PreProcessor/ProcessedArgs.cs b/src/SonarScanner.MSBuild.PreProcessor/ProcessedArgs.cs index 3646647c1..c559b68be 100644 --- a/src/SonarScanner.MSBuild.PreProcessor/ProcessedArgs.cs +++ b/src/SonarScanner.MSBuild.PreProcessor/ProcessedArgs.cs @@ -168,12 +168,6 @@ public ProcessedArgs( ? architecture.Value : RuntimeInformation.OSArchitecture.ToString().ToLowerInvariant(); - if (AggregateProperties.HasProperty(SonarProperties.SonarSources) - || AggregateProperties.HasProperty(SonarProperties.SonarTests)) - { - IsValid = false; - logger.LogError(Resources.ERROR_SonarSourcesAndTestsNotSupported); - } if (AggregateProperties.TryGetProperty(SonarProperties.JavaExePath, out var javaExePath)) { if (!fileWrapper.Exists(javaExePath.Value)) diff --git a/src/SonarScanner.MSBuild.Shim/AdditionalFilesService.cs b/src/SonarScanner.MSBuild.Shim/AdditionalFilesService.cs index 8c7ba36ea..14fda8336 100644 --- a/src/SonarScanner.MSBuild.Shim/AdditionalFilesService.cs +++ b/src/SonarScanner.MSBuild.Shim/AdditionalFilesService.cs @@ -102,7 +102,11 @@ private static bool IsExcludedDirectory(DirectoryInfo directory) => part => part.Equals(x, StringComparison.OrdinalIgnoreCase))); private static string FirstUserSpecifiedSonarParameter(AnalysisConfig analysisConfig) => - SonarProperties.ScanAllWarningParameters.FirstOrDefault(x => analysisConfig.LocalSettings.Exists(setting => setting.Id == x)); + FirstUserSpecifiedSonarParameter(analysisConfig.LocalSettings) + ?? FirstUserSpecifiedSonarParameter(analysisConfig.ServerSettings); + + private static string FirstUserSpecifiedSonarParameter(AnalysisProperties properties) => + SonarProperties.ScanAllWarningParameters.FirstOrDefault(x => properties.Exists(setting => setting.Id == x)); private static AdditionalFiles PartitionAdditionalFiles(FileInfo[] allFiles, AnalysisConfig analysisConfig) {