Skip to content

Commit

Permalink
Multi-language support: Re-enable sonar.sources and sonar.tests
Browse files Browse the repository at this point in the history
  • Loading branch information
gregory-paidis-sonarsource committed Sep 6, 2024
1 parent 6afe704 commit 1414371
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 21 deletions.
14 changes: 0 additions & 14 deletions Tests/SonarScanner.MSBuild.PreProcessor.Test/ProcessedArgsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -134,20 +134,6 @@ public void ProcArgs_ParameterThrow_ScannerEnvProperties()
action.Should().Throw<ArgumentNullException>().WithParameterName("scannerEnvProperties");
}

[DataTestMethod]
[DataRow("sonar.sources")]
[DataRow("sonar.tests")]
public void ProcArgs_InvalidPropertiesSet(string propertyName)
{
var provider = Substitute.For<IAnalysisPropertyProvider>();
provider.HasProperty(propertyName).Returns(true);

args = CreateDefaultArgs(provider);

args.IsValid.Should().BeFalse();
logger.AssertSingleErrorExists("The arguments 'sonar.sources' and 'sonar.tests' are not supported. Please remove them and invoke the scanner again.");
}

[TestMethod]
public void ProcArgs_Organization()
{
Expand Down
6 changes: 0 additions & 6 deletions src/SonarScanner.MSBuild.PreProcessor/ProcessedArgs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
6 changes: 5 additions & 1 deletion src/SonarScanner.MSBuild.Shim/AdditionalFilesService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down

0 comments on commit 1414371

Please sign in to comment.