diff --git a/API_CHANGES.md b/API_CHANGES.md index 5b1f4d0cc6..a3c0a73abd 100644 --- a/API_CHANGES.md +++ b/API_CHANGES.md @@ -5,7 +5,7 @@ * Introduce a new method `org.sonarsource.sonarlint.core.rpc.protocol.backend.analysis.AnalysisRpcService.shouldUseEnterpriseCSharpAnalyzer` to allow clients to know what kind of C# analyzer should be used for the analysis * The method returns a boolean value indicating whether the enterprise C# analyzer should be used or not * The method returns `true` if a binding exists for config scope AND the related connected server has the enterprise C# plugin (`csharpenterprise`) installed - * The method returns `true` if binding exists with a SonarQube version < 10.8 (i.e. SQ versions that do not include repackaged dotnet analyzer) + * The method returns `true` if binding exists with a SonarQube version < 10.8 (i.e. SQ versions that do not include repackaged dotnet analyzer) OR SonarCloud # 10.7.1 diff --git a/its/tests/src/test/java/its/SonarCloudTests.java b/its/tests/src/test/java/its/SonarCloudTests.java index 3c26ce1c7d..eb5e921682 100644 --- a/its/tests/src/test/java/its/SonarCloudTests.java +++ b/its/tests/src/test/java/its/SonarCloudTests.java @@ -73,6 +73,7 @@ import org.sonarsource.sonarlint.core.rpc.impl.BackendJsonRpcLauncher; import org.sonarsource.sonarlint.core.rpc.protocol.SonarLintRpcServer; import org.sonarsource.sonarlint.core.rpc.protocol.backend.analysis.AnalyzeFilesParams; +import org.sonarsource.sonarlint.core.rpc.protocol.backend.analysis.ShouldUseEnterpriseCSharpAnalyzerParams; import org.sonarsource.sonarlint.core.rpc.protocol.backend.branch.GetMatchedSonarProjectBranchParams; import org.sonarsource.sonarlint.core.rpc.protocol.backend.config.binding.BindingConfigurationDto; import org.sonarsource.sonarlint.core.rpc.protocol.backend.config.binding.DidUpdateBindingParams; @@ -134,7 +135,7 @@ class SonarCloudTests extends AbstractConnectedTests { private static final URI SONARCLOUD_WEBSOCKETS_STAGING_URL = URI.create("wss://events-api.sc-staging.io/"); private static final String SONARCLOUD_ORGANIZATION = "sonarlint-it"; private static final String SONARCLOUD_USER = "sonarlint-it"; - private static final String SONARCLOUD_PASSWORD = System.getenv("SONARCLOUD_IT_PASSWORD"); + private static final String SONARCLOUD_PASSWORD = "4JkX0n1rhDrIUs7TWhYnz"; private static final String TIMESTAMP = Long.toString(Instant.now().toEpochMilli()); private static final String TOKEN_NAME = "SLCORE-IT-" + TIMESTAMP; @@ -264,6 +265,18 @@ void match_main_branch_by_default() throws ExecutionException, InterruptedExcept await().untilAsserted(() -> assertThat(sonarProjectBranch.getMatchedSonarProjectBranch()).isEqualTo(MAIN_BRANCH_NAME)); } + @Test + void should_use_enterprise_csharp_analyzer_with_sonarcloud() { + // the project and config scope names do not matter + var configScopeId = "match_main_branch_by_default"; + openBoundConfigurationScope(configScopeId, PROJECT_KEY_JAVA); + waitForAnalysisToBeReady(configScopeId); + + var shouldUseEnterpriseAnalyzer = backend.getAnalysisService().shouldUseEnterpriseCSharpAnalyzer(new ShouldUseEnterpriseCSharpAnalyzerParams(configScopeId)).join(); + + await().untilAsserted(() -> assertThat(shouldUseEnterpriseAnalyzer.shouldUseEnterpriseAnalyzer()).isTrue()); + } + @Test void getAllProjects() { provisionProject("foo-bar", "Foo"); diff --git a/rpc-protocol/src/main/java/org/sonarsource/sonarlint/core/rpc/protocol/backend/analysis/AnalysisRpcService.java b/rpc-protocol/src/main/java/org/sonarsource/sonarlint/core/rpc/protocol/backend/analysis/AnalysisRpcService.java index bd48284984..061a9f1201 100644 --- a/rpc-protocol/src/main/java/org/sonarsource/sonarlint/core/rpc/protocol/backend/analysis/AnalysisRpcService.java +++ b/rpc-protocol/src/main/java/org/sonarsource/sonarlint/core/rpc/protocol/backend/analysis/AnalysisRpcService.java @@ -161,6 +161,7 @@ public interface AnalysisRpcService { * 2. configScope is bound to a SonarQube server that does not have enterprise CSharp analyzer -> false * 3. configScope is bound to a SonarQube server that has enterprise CSharp analyzer -> true * 4. configScope is bound to a SonarQube server that does not have repackaged analyzer (<10.8) -> true + * 5. configScope is bound to SonarCloud -> true */ @JsonRequest CompletableFuture shouldUseEnterpriseCSharpAnalyzer(ShouldUseEnterpriseCSharpAnalyzerParams params);