From b482eda41a1b356dfdf7d38d110197762249843d Mon Sep 17 00:00:00 2001 From: Martin Strecker <103252490+martin-strecker-sonarsource@users.noreply.github.com> Date: Tue, 20 Aug 2024 17:14:06 +0200 Subject: [PATCH] SCAN4NET-18 Better messages for Multi-file analysis (#2156) --- .../PostProcessorTests.cs | 7 ++++--- .../PropertiesFileGeneratorTests.cs | 2 +- .../it/scanner/msbuild/sonarqube/ScannerMSBuildTest.java | 6 +++--- .../Resources.Designer.cs | 2 +- src/SonarScanner.MSBuild.PostProcessor/Resources.resx | 2 +- src/SonarScanner.MSBuild.Shim/Resources.Designer.cs | 3 ++- src/SonarScanner.MSBuild.Shim/Resources.resx | 2 +- 7 files changed, 13 insertions(+), 11 deletions(-) diff --git a/Tests/SonarScanner.MSBuild.PostProcessor.Test/PostProcessorTests.cs b/Tests/SonarScanner.MSBuild.PostProcessor.Test/PostProcessorTests.cs index 86e1df3bd..e964f03d7 100644 --- a/Tests/SonarScanner.MSBuild.PostProcessor.Test/PostProcessorTests.cs +++ b/Tests/SonarScanner.MSBuild.PostProcessor.Test/PostProcessorTests.cs @@ -92,7 +92,7 @@ public void PostProc_NoProjectsToAnalyze_NoExecutionTriggered() context.TfsProcessor.AssertNotExecuted(); context.Scanner.AssertNotExecuted(); context.Logger.AssertErrorsLogged(0); - context.Logger.AssertSingleWarningExists("""Multi-Language analysis is enabled. If this was not intended, please set "/d:sonar.scanner.scanAll=false" in the begin step."""); + context.Logger.AssertSingleWarningExists("""Multi-Language analysis is enabled. If this was not intended and you have issues such as hitting your LOC limit or analyzing unwanted files, please set "/d:sonar.scanner.scanAll=false" in the begin step."""); context.VerifyTargetsUninstaller(); fileWrapper.Received(1).WriteAllText( @@ -100,7 +100,7 @@ public void PostProc_NoProjectsToAnalyze_NoExecutionTriggered() """ [ { - "text": "Multi-Language analysis is enabled. If this was not intended, please set \"/d:sonar.scanner.scanAll=false\" in the begin step." + "text": "Multi-Language analysis is enabled. If this was not intended and you have issues such as hitting your LOC limit or analyzing unwanted files, please set \"/d:sonar.scanner.scanAll=false\" in the begin step." } ] """); @@ -192,7 +192,8 @@ public void PostProc_ValidArgsPassedThrough() context.Scanner.AssertExecuted(); context.Scanner.SuppliedCommandLineArgs.Should().Equal(expectedArgs, "Unexpected command line args passed to the sonar-scanner"); context.Logger.AssertErrorsLogged(0); - context.Logger.AssertSingleWarningExists("""Multi-Language analysis is enabled. If this was not intended, please set "/d:sonar.scanner.scanAll=false" in the begin step."""); + context.Logger.AssertSingleWarningExists("""Multi-Language analysis is enabled. """ + + """If this was not intended and you have issues such as hitting your LOC limit or analyzing unwanted files, please set "/d:sonar.scanner.scanAll=false" in the begin step."""); context.VerifyTargetsUninstaller(); } diff --git a/Tests/SonarScanner.MSBuild.Shim.Test/PropertiesFileGeneratorTests.cs b/Tests/SonarScanner.MSBuild.Shim.Test/PropertiesFileGeneratorTests.cs index 855a0763e..34351759d 100644 --- a/Tests/SonarScanner.MSBuild.Shim.Test/PropertiesFileGeneratorTests.cs +++ b/Tests/SonarScanner.MSBuild.Shim.Test/PropertiesFileGeneratorTests.cs @@ -865,7 +865,7 @@ public void TryWriteProperties_WhenThereIsNoCommonPath_LogsError() // create a project in the test run directory and a second one in the temp folder. sut.TryWriteProperties(new PropertiesWriter(config, this.logger), [firstProjectInfo, secondProjectInfo], out _); - logger.AssertErrorLogged("The project base directory cannot be automatically detected. Please specify the `sonar.projectBaseDir` on the begin step."); + logger.AssertErrorLogged("""The project base directory cannot be automatically detected. Please specify the "/d:sonar.projectBaseDir" on the begin step."""); } [TestMethod] diff --git a/its/src/test/java/com/sonar/it/scanner/msbuild/sonarqube/ScannerMSBuildTest.java b/its/src/test/java/com/sonar/it/scanner/msbuild/sonarqube/ScannerMSBuildTest.java index cea7473f1..6c8ba82d0 100644 --- a/its/src/test/java/com/sonar/it/scanner/msbuild/sonarqube/ScannerMSBuildTest.java +++ b/its/src/test/java/com/sonar/it/scanner/msbuild/sonarqube/ScannerMSBuildTest.java @@ -1101,7 +1101,7 @@ void checkMultiLanguageSupportReact() throws Exception { Arrays.asList( new EnvironmentVariable("AGENT_BUILDDIRECTORY", ""), new EnvironmentVariable("BUILD_SOURCESDIRECTORY", "")), - TestUtils.TIMEOUT_LIMIT, + TestUtils.TIMEOUT_LIMIT * 5, // Longer timeout because of npm install "/t:Restore,Rebuild", "MultiLanguageSupportReact.csproj" ); @@ -1158,7 +1158,7 @@ void checkMultiLanguageSupportAngular() throws Exception { Arrays.asList( new EnvironmentVariable("AGENT_BUILDDIRECTORY", ""), new EnvironmentVariable("BUILD_SOURCESDIRECTORY", "")), - TestUtils.TIMEOUT_LIMIT, + TestUtils.TIMEOUT_LIMIT * 5, // Longer timeout because of npm install "/t:Restore,Rebuild", "MultiLanguageSupportAngular.csproj" ); @@ -1252,7 +1252,7 @@ private void assertOnlyMultiFileAnalysisWarning(BuildResult buildResult) { var warnings = TestUtils.getAnalysisWarningsTask(ORCHESTRATOR, buildResult); assertThat(warnings.getStatus()).isEqualTo(Ce.TaskStatus.SUCCESS); assertThat(warnings.getWarningsList()).containsExactly( - "Multi-Language analysis is enabled. If this was not intended, please set \"/d:sonar.scanner.scanAll=false\" in the begin step."); + "Multi-Language analysis is enabled. If this was not intended and you have issues such as hitting your LOC limit or analyzing unwanted files, please set \"/d:sonar.scanner.scanAll=false\" in the begin step."); } private void runCSharpSharedFileWithOneProjectUsingProjectBaseDir(Function getProjectBaseDir) diff --git a/src/SonarScanner.MSBuild.PostProcessor/Resources.Designer.cs b/src/SonarScanner.MSBuild.PostProcessor/Resources.Designer.cs index 1c988bffc..a946fd6a7 100644 --- a/src/SonarScanner.MSBuild.PostProcessor/Resources.Designer.cs +++ b/src/SonarScanner.MSBuild.PostProcessor/Resources.Designer.cs @@ -251,7 +251,7 @@ internal static string WARN_CannotProcessCoverage { } /// - /// Looks up a localized string similar to Multi-Language analysis is enabled. If this was not intended, please set "/d:sonar.scanner.scanAll=false" in the begin step.. + /// Looks up a localized string similar to Multi-Language analysis is enabled. If this was not intended and you have issues such as hitting your LOC limit or analyzing unwanted files, please set "/d:sonar.scanner.scanAll=false" in the begin step.. /// internal static string WARN_UI_ScanAllAnalysisEnabled { get { diff --git a/src/SonarScanner.MSBuild.PostProcessor/Resources.resx b/src/SonarScanner.MSBuild.PostProcessor/Resources.resx index 9b7b88d95..9a188b0c7 100644 --- a/src/SonarScanner.MSBuild.PostProcessor/Resources.resx +++ b/src/SonarScanner.MSBuild.PostProcessor/Resources.resx @@ -188,6 +188,6 @@ Config file: {5} Cannot process the code coverage information. Look at the previous warnings for details. - Multi-Language analysis is enabled. If this was not intended, please set "/d:sonar.scanner.scanAll=false" in the begin step. + Multi-Language analysis is enabled. If this was not intended and you have issues such as hitting your LOC limit or analyzing unwanted files, please set "/d:sonar.scanner.scanAll=false" in the begin step. \ No newline at end of file diff --git a/src/SonarScanner.MSBuild.Shim/Resources.Designer.cs b/src/SonarScanner.MSBuild.Shim/Resources.Designer.cs index ce57c6134..adcc020d6 100644 --- a/src/SonarScanner.MSBuild.Shim/Resources.Designer.cs +++ b/src/SonarScanner.MSBuild.Shim/Resources.Designer.cs @@ -1,6 +1,7 @@ //------------------------------------------------------------------------------ // // This code was generated by a tool. +// Runtime Version:4.0.30319.42000 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. @@ -104,7 +105,7 @@ internal static string ERR_NoValidProjectInfoFiles { } /// - /// Looks up a localized string similar to The project base directory cannot be automatically detected. Please specify the `sonar.projectBaseDir` on the begin step.. + /// Looks up a localized string similar to The project base directory cannot be automatically detected. Please specify the "/d:sonar.projectBaseDir" on the begin step.. /// internal static string ERR_ProjectBaseDirCannotBeAutomaticallyDetected { get { diff --git a/src/SonarScanner.MSBuild.Shim/Resources.resx b/src/SonarScanner.MSBuild.Shim/Resources.resx index cb2137ccb..469d98d4e 100644 --- a/src/SonarScanner.MSBuild.Shim/Resources.resx +++ b/src/SonarScanner.MSBuild.Shim/Resources.resx @@ -222,7 +222,7 @@ Possible causes: File was referenced by the following projects: '{0}'. - The project base directory cannot be automatically detected. Please specify the `sonar.projectBaseDir` on the begin step. + The project base directory cannot be automatically detected. Please specify the "/d:sonar.projectBaseDir" on the begin step. The project base directory doesn't exist.