diff --git a/src/main/java/org/sonarsource/sonarlint/ls/CommandManager.java b/src/main/java/org/sonarsource/sonarlint/ls/CommandManager.java index fd0409608..cd36da92d 100644 --- a/src/main/java/org/sonarsource/sonarlint/ls/CommandManager.java +++ b/src/main/java/org/sonarsource/sonarlint/ls/CommandManager.java @@ -120,7 +120,7 @@ public class CommandManager { // Client side static final String SONARLINT_DEACTIVATE_RULE_COMMAND = "SonarLint.DeactivateRule"; static final String RESOLVE_ISSUE = "SonarLint.ResolveIssue"; - static final String SONARLINT_ACTION_PREFIX = "SonarLint: "; + static final String SONARLINT_ACTION_PREFIX = "SonarQube: "; private final SonarLintExtendedLanguageClient client; private final SettingsManager settingsManager; diff --git a/src/main/java/org/sonarsource/sonarlint/ls/DiagnosticPublisher.java b/src/main/java/org/sonarsource/sonarlint/ls/DiagnosticPublisher.java index d0ac2df18..64285debb 100644 --- a/src/main/java/org/sonarsource/sonarlint/ls/DiagnosticPublisher.java +++ b/src/main/java/org/sonarsource/sonarlint/ls/DiagnosticPublisher.java @@ -39,7 +39,7 @@ public class DiagnosticPublisher { - static final String SONARLINT_SOURCE = "sonarlint"; + static final String SONARLINT_SOURCE = "sonarqube"; static final String REMOTE_SOURCE = "remote"; public static final String ITEM_LOCATION = "location"; diff --git a/src/main/java/org/sonarsource/sonarlint/ls/SkippedPluginsNotifier.java b/src/main/java/org/sonarsource/sonarlint/ls/SkippedPluginsNotifier.java index 5a43c23b8..9feef4769 100644 --- a/src/main/java/org/sonarsource/sonarlint/ls/SkippedPluginsNotifier.java +++ b/src/main/java/org/sonarsource/sonarlint/ls/SkippedPluginsNotifier.java @@ -52,7 +52,7 @@ public SkippedPluginsNotifier(SonarLintExtendedLanguageClient client, LanguageCl } public void notifyOnceForSkippedPlugins(Language language, DidSkipLoadingPluginParams.SkipReason reason, String minVersion, @Nullable String currentVersion) { - final var title = String.format("SonarLint failed to analyze %s code", LSLanguage.valueOf(language.name()).getLabel()); + final var title = String.format("SonarQube for VS Code failed to analyze %s code", LSLanguage.valueOf(language.name()).getLabel()); if (reason == DidSkipLoadingPluginParams.SkipReason.UNSATISFIED_JRE) { handleMissingJRERequirement(minVersion, Objects.requireNonNull(currentVersion), title); } else if (reason == DidSkipLoadingPluginParams.SkipReason.UNSATISFIED_NODE_JS) { diff --git a/src/main/java/org/sonarsource/sonarlint/ls/SonarLintLanguageServer.java b/src/main/java/org/sonarsource/sonarlint/ls/SonarLintLanguageServer.java index a411f5efe..705d5c89c 100644 --- a/src/main/java/org/sonarsource/sonarlint/ls/SonarLintLanguageServer.java +++ b/src/main/java/org/sonarsource/sonarlint/ls/SonarLintLanguageServer.java @@ -196,7 +196,7 @@ public class SonarLintLanguageServer implements SonarLintExtendedLanguageServer, private final ExecutorService branchChangeEventExecutor; SonarLintLanguageServer(InputStream inputStream, OutputStream outputStream, Collection analyzers) { - this.lspThreadPool = Executors.newCachedThreadPool(Utils.threadFactory("SonarLint LSP message processor", false)); + this.lspThreadPool = Executors.newCachedThreadPool(Utils.threadFactory("SonarQube for VS Code LSP message processor", false)); var input = new ExitingInputStream(inputStream, this); var launcher = new Launcher.Builder() @@ -206,7 +206,7 @@ public class SonarLintLanguageServer implements SonarLintExtendedLanguageServer, .setOutput(outputStream) .setExecutorService(lspThreadPool) .create(); - this.branchChangeEventExecutor = Executors.newSingleThreadExecutor(Utils.threadFactory("SonarLint branch change event handler", false)); + this.branchChangeEventExecutor = Executors.newSingleThreadExecutor(Utils.threadFactory("SonarQube for VS Code branch change event handler", false)); this.analyzers = analyzers; this.client = launcher.getRemoteProxy(); @@ -864,7 +864,7 @@ public CompletableFuture changeIssueStatus(ChangeIssueStatusParams params) client.showMessage(new MessageParams(MessageType.Info, "Issue status was changed")); }).exceptionally(t -> { lsLogOutput.errorWithStackTrace("Error changing issue status", t); - client.showMessage(new MessageParams(MessageType.Error, "Could not change status for the issue. Look at the SonarLint output for details.")); + client.showMessage(new MessageParams(MessageType.Error, "Could not change status for the issue. Look at the SonarQube for IDE output for details.")); return null; }).thenAccept(unused -> { if (!StringUtils.isEmpty(params.getComment())) { @@ -910,7 +910,7 @@ public CompletableFuture changeHotspotStatus(ChangeHotspotStatusParams par client.showMessage(new MessageParams(MessageType.Info, "Hotspot status was changed")); }).exceptionally(t -> { lsLogOutput.errorWithStackTrace("Error changing hotspot status", t); - client.showMessage(new MessageParams(MessageType.Error, "Could not change status for the hotspot. Look at the SonarLint output for details.")); + client.showMessage(new MessageParams(MessageType.Error, "Could not change status for the hotspot. Look at the SonarQube for IDE output for details.")); return null; }); } @@ -936,7 +936,7 @@ public CompletableFuture getAllowedHotspotSta statuses); }).exceptionally(t -> { lsLogOutput.errorWithStackTrace("Error changing hotspot status", t); - client.showMessage(new MessageParams(MessageType.Error, "Could not change status for the hotspot. Look at the SonarLint output for details.")); + client.showMessage(new MessageParams(MessageType.Error, "Could not change status for the hotspot. Look at the SonarQube for IDE output for details.")); return null; }); } @@ -957,7 +957,7 @@ public void reopenResolvedLocalIssues(ReopenAllIssuesForFileParams params) { return r; }).exceptionally(e -> { lsLogOutput.errorWithStackTrace("Error while reopening resolved local issues", e); - client.showMessage(new MessageParams(MessageType.Error, "Could not reopen resolved local issues. Look at the SonarLint output for details.")); + client.showMessage(new MessageParams(MessageType.Error, "Could not reopen resolved local issues. Look at the SonarQube for IDE output for details.")); return null; }); } diff --git a/src/main/java/org/sonarsource/sonarlint/ls/backend/BackendService.java b/src/main/java/org/sonarsource/sonarlint/ls/backend/BackendService.java index e42fa6c3b..d0210dabe 100644 --- a/src/main/java/org/sonarsource/sonarlint/ls/backend/BackendService.java +++ b/src/main/java/org/sonarsource/sonarlint/ls/backend/BackendService.java @@ -265,7 +265,7 @@ public void didChangeClientNodeJsPath(DidChangeClientNodeJsPathParams params) { .exceptionally(t -> { logOutput.errorWithStackTrace("Error getting issue status change permissions", t); client.logMessage(new MessageParams(MessageType.Error, "Could not get issue status change for issue \"" - + issueKey + "\". Look at the SonarLint output for details.")); + + issueKey + "\". Look at the SonarQube for IDE output for details.")); return null; }); } @@ -278,7 +278,7 @@ public CompletableFuture addIssueComment(AddIssueCommentParams params) { return initializedBackend().getIssueService().addComment(params) .exceptionally(t -> { logOutput.errorWithStackTrace("Error adding issue comment", t); - client.showMessage(new MessageParams(MessageType.Error, "Could not add a new issue comment. Look at the SonarLint output for " + + client.showMessage(new MessageParams(MessageType.Error, "Could not add a new issue comment. Look at the SonarQube for IDE output for " + "details.")); return null; }); diff --git a/src/main/java/org/sonarsource/sonarlint/ls/clientapi/SonarLintVSCodeClient.java b/src/main/java/org/sonarsource/sonarlint/ls/clientapi/SonarLintVSCodeClient.java index d31be48d7..43edcea7a 100644 --- a/src/main/java/org/sonarsource/sonarlint/ls/clientapi/SonarLintVSCodeClient.java +++ b/src/main/java/org/sonarsource/sonarlint/ls/clientapi/SonarLintVSCodeClient.java @@ -125,7 +125,7 @@ public class SonarLintVSCodeClient implements SonarLintRpcClientDelegate { - public static final String SONARLINT_SOURCE = "sonarlint"; + public static final String SONARLINT_SOURCE = "sonarqube"; private final SonarLintExtendedLanguageClient client; private SettingsManager settingsManager; private SmartNotifications smartNotifications; @@ -296,7 +296,7 @@ public AssistBindingResponse assistBinding(AssistBindingParams params, SonarLint @Override public void noBindingSuggestionFound(NoBindingSuggestionFoundParams params) { var messageRequestParams = new ShowMessageRequestParams(); - messageRequestParams.setMessage("SonarLint couldn't match the server project '" + params.getProjectKey() + "' to any of the currently " + + messageRequestParams.setMessage("SonarQube for VS Code couldn't match the server project '" + params.getProjectKey() + "' to any of the currently " + "open workspace folders. Please make sure the project is open in the workspace, or try configuring the binding manually."); messageRequestParams.setType(MessageType.Error); var learnMoreAction = new MessageActionItem("Learn more"); diff --git a/src/test/java/org/sonarsource/sonarlint/ls/CommandManagerTests.java b/src/test/java/org/sonarsource/sonarlint/ls/CommandManagerTests.java index 4b01bc066..00586008f 100644 --- a/src/test/java/org/sonarsource/sonarlint/ls/CommandManagerTests.java +++ b/src/test/java/org/sonarsource/sonarlint/ls/CommandManagerTests.java @@ -191,8 +191,8 @@ void noDisableRuleForBoundProject() { var codeActions = underTest.computeCodeActions(new CodeActionParams(FAKE_TEXT_DOCUMENT, FAKE_RANGE, new CodeActionContext(List.of(new Diagnostic(FAKE_RANGE, "Foo", DiagnosticSeverity.Error, SONARLINT_SOURCE, "XYZ")))), NOP_CANCEL_TOKEN); - assertThat(codeActions).extracting(c -> c.getRight().getTitle()).containsOnly("SonarLint: Show issue details for 'XYZ'", - "SonarLint: Resolve issue violating rule 'XYZ' as..."); + assertThat(codeActions).extracting(c -> c.getRight().getTitle()).containsOnly("SonarQube: Show issue details for 'XYZ'", + "SonarQube: Resolve issue violating rule 'XYZ' as..."); } @Test @@ -210,8 +210,8 @@ void suggestDisableRuleForUnboundProject() { assertThat(codeActions).extracting(c -> c.getRight().getTitle()) .containsOnly( - "SonarLint: Show issue details for 'XYZ'", - "SonarLint: Deactivate rule 'XYZ'"); + "SonarQube: Show issue details for 'XYZ'", + "SonarQube: Deactivate rule 'XYZ'"); } @Test @@ -241,9 +241,9 @@ void showQuickFixFromAnalyzer() { assertThat(codeActions).extracting(c -> c.getRight().getTitle()) .containsExactly( - "SonarLint: Fix the issue!", - "SonarLint: Show issue details for 'XYZ'", - "SonarLint: Deactivate rule 'XYZ'"); + "SonarQube: Fix the issue!", + "SonarQube: Show issue details for 'XYZ'", + "SonarQube: Deactivate rule 'XYZ'"); } @Test @@ -280,9 +280,9 @@ void showQuickFixFromAnalyzerForNotebook() { assertThat(codeActions).extracting(c -> c.getRight().getTitle()) .containsExactly( - "SonarLint: Fix the issue!", - "SonarLint: Show issue details for 'XYZ'", - "SonarLint: Deactivate rule 'XYZ'"); + "SonarQube: Fix the issue!", + "SonarQube: Show issue details for 'XYZ'", + "SonarQube: Deactivate rule 'XYZ'"); } @ParameterizedTest @@ -320,10 +320,10 @@ void codeActionsForTaintWithContext(String taintSource) { new CodeActionContext(List.of(d))), NOP_CANCEL_TOKEN); assertThat(codeActions).extracting(c -> c.getRight().getTitle()).containsOnly( - "SonarLint: Show issue details for 'ruleKey'", - "SonarLint: Show all locations for taint vulnerability 'ruleKey'", - "SonarLint: Open taint vulnerability 'ruleKey' on 'connectionId'", - "SonarLint: Resolve issue violating rule 'ruleKey' as..."); + "SonarQube: Show issue details for 'ruleKey'", + "SonarQube: Show all locations for taint vulnerability 'ruleKey'", + "SonarQube: Open taint vulnerability 'ruleKey' on 'connectionId'", + "SonarQube: Resolve issue violating rule 'ruleKey' as..."); assertThat(codeActions.get(0).getRight().getCommand().getArguments()).containsOnly( issueId, @@ -358,9 +358,9 @@ void codeActionsForTaintNoContext() { new CodeActionContext(List.of(d))), NOP_CANCEL_TOKEN); assertThat(codeActions).extracting(c -> c.getRight().getTitle()).containsOnly( - "SonarLint: Show issue details for 'ruleKey'", - "SonarLint: Open taint vulnerability 'ruleKey' on 'connectionId'", - "SonarLint: Resolve issue violating rule 'ruleKey' as..."); + "SonarQube: Show issue details for 'ruleKey'", + "SonarQube: Open taint vulnerability 'ruleKey' on 'connectionId'", + "SonarQube: Resolve issue violating rule 'ruleKey' as..."); assertThat(codeActions.get(0).getRight().getCommand().getArguments()).containsOnly( taintId, @@ -388,9 +388,9 @@ void suggestShowAllLocationsForIssueWithFlows() { assertThat(codeActions).extracting(c -> c.getRight().getTitle()) .containsOnly( - "SonarLint: Show issue details for 'XYZ'", - "SonarLint: Deactivate rule 'XYZ'", - "SonarLint: Show all locations for issue 'XYZ'"); + "SonarQube: Show issue details for 'XYZ'", + "SonarQube: Deactivate rule 'XYZ'", + "SonarQube: Show all locations for issue 'XYZ'"); } @Test @@ -723,8 +723,8 @@ void hasResolveIssueActionForBoundProject() { assertThat(codeActions).extracting(c -> c.getRight().getTitle()) .containsExactly( - "SonarLint: Resolve issue violating rule 'XYZ' as...", - "SonarLint: Show issue details for 'XYZ'"); + "SonarQube: Resolve issue violating rule 'XYZ' as...", + "SonarQube: Show issue details for 'XYZ'"); } @Test @@ -759,7 +759,7 @@ void doesNotHaveResolveIssueActionWhenIssueStatusChangeNotPermitted() { assertThat(codeActions).extracting(c -> c.getRight().getTitle()) .containsExactly( - "SonarLint: Show issue details for 'XYZ'"); + "SonarQube: Show issue details for 'XYZ'"); } } diff --git a/src/test/java/org/sonarsource/sonarlint/ls/SkippedPluginsNotifierTests.java b/src/test/java/org/sonarsource/sonarlint/ls/SkippedPluginsNotifierTests.java index b6fdaf5e3..ed60273a4 100644 --- a/src/test/java/org/sonarsource/sonarlint/ls/SkippedPluginsNotifierTests.java +++ b/src/test/java/org/sonarsource/sonarlint/ls/SkippedPluginsNotifierTests.java @@ -74,7 +74,7 @@ void send_notification_once_for_jre() { verify(languageClient, times(1)).openJavaHomeSettings(); var message = messageCaptor.getValue(); - assertThat(message.getMessage()).contains("SonarLint failed to analyze Java code") + assertThat(message.getMessage()).contains("SonarQube for VS Code failed to analyze Java code") .contains("Java runtime version 17 or later is required. Current version is 11."); assertThat(message.getActions()).containsExactly(SkippedPluginsNotifier.ACTION_OPEN_SETTINGS); } @@ -89,7 +89,7 @@ void send_notification_for_jre_and_close_notification() { verify(languageClient, times(1)).showMessageRequest(messageCaptor.capture()); var message = messageCaptor.getValue(); - assertThat(message.getMessage()).contains("SonarLint failed to analyze Java code") + assertThat(message.getMessage()).contains("SonarQube for VS Code failed to analyze Java code") .contains("Java runtime version 17 or later is required. Current version is 11."); assertThat(message.getActions()).containsExactly(SkippedPluginsNotifier.ACTION_OPEN_SETTINGS); } @@ -105,7 +105,7 @@ void send_notification_for_node_when_found() { verify(languageClient, times(1)).openPathToNodeSettings(); var message = messageCaptor.getValue(); - assertThat(message.getMessage()).contains("SonarLint failed to analyze JavaScript code") + assertThat(message.getMessage()).contains("SonarQube for VS Code failed to analyze JavaScript code") .contains("Node.js runtime version minNodeJsVersion or later is required. Current version is currentNodeJsVersion."); assertThat(message.getActions()).containsExactly(SkippedPluginsNotifier.ACTION_OPEN_SETTINGS, SkippedPluginsNotifier.ACTION_DONT_SHOW_AGAIN); } @@ -120,7 +120,7 @@ void send_notification_for_node_when_not_found() { verify(languageClient, times(1)).showMessageRequest(messageCaptor.capture()); var message = messageCaptor.getValue(); - assertThat(message.getMessage()).contains("SonarLint failed to analyze JavaScript code") + assertThat(message.getMessage()).contains("SonarQube for VS Code failed to analyze JavaScript code") .contains("Node.js runtime version minNodeJsVersion or later is required.") .doesNotContain("Current version is"); assertThat(message.getActions()).containsExactly(SkippedPluginsNotifier.ACTION_OPEN_SETTINGS, SkippedPluginsNotifier.ACTION_DONT_SHOW_AGAIN); @@ -138,7 +138,7 @@ void should_turn_off_notifications_when_user_opts_out() { verify(languageClient, never()).openPathToNodeSettings(); var message = messageCaptor.getValue(); - assertThat(message.getMessage()).contains("SonarLint failed to analyze JavaScript code") + assertThat(message.getMessage()).contains("SonarQube for VS Code failed to analyze JavaScript code") .contains("Node.js runtime version minNodeJsVersion or later is required. Current version is currentNodeJsVersion."); assertThat(message.getActions()).containsExactly(SkippedPluginsNotifier.ACTION_OPEN_SETTINGS, SkippedPluginsNotifier.ACTION_DONT_SHOW_AGAIN); } diff --git a/src/test/java/org/sonarsource/sonarlint/ls/backend/BackendServiceTests.java b/src/test/java/org/sonarsource/sonarlint/ls/backend/BackendServiceTests.java index 22387913a..746d42f67 100644 --- a/src/test/java/org/sonarsource/sonarlint/ls/backend/BackendServiceTests.java +++ b/src/test/java/org/sonarsource/sonarlint/ls/backend/BackendServiceTests.java @@ -20,12 +20,16 @@ package org.sonarsource.sonarlint.ls.backend; import java.util.Optional; +import java.util.UUID; import java.util.concurrent.CompletableFuture; +import org.eclipse.lsp4j.MessageParams; +import org.eclipse.lsp4j.MessageType; import org.eclipse.lsp4j.WorkspaceFolder; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.mockito.ArgumentCaptor; +import org.sonarsource.sonarlint.core.issue.IssueNotFoundException; import org.sonarsource.sonarlint.core.rpc.protocol.SonarLintRpcServer; import org.sonarsource.sonarlint.core.rpc.protocol.backend.binding.BindingRpcService; import org.sonarsource.sonarlint.core.rpc.protocol.backend.binding.GetSharedConnectedModeConfigFileParams; @@ -35,6 +39,8 @@ import org.sonarsource.sonarlint.core.rpc.protocol.backend.connection.org.ListUserOrganizationsParams; import org.sonarsource.sonarlint.core.rpc.protocol.backend.hotspot.HotspotRpcService; import org.sonarsource.sonarlint.core.rpc.protocol.backend.hotspot.OpenHotspotInBrowserParams; +import org.sonarsource.sonarlint.core.rpc.protocol.backend.issue.AddIssueCommentParams; +import org.sonarsource.sonarlint.core.rpc.protocol.backend.issue.IssueRpcService; import org.sonarsource.sonarlint.ls.SonarLintExtendedLanguageClient; import org.sonarsource.sonarlint.ls.connected.ProjectBinding; import org.sonarsource.sonarlint.ls.log.LanguageClientLogger; @@ -52,6 +58,7 @@ class BackendServiceTests { ConfigurationRpcService configurationService = mock(ConfigurationRpcService.class); BindingRpcService bindingRpcService = mock(BindingRpcService.class); ConnectionRpcService connectionRpcService = mock(ConnectionRpcService.class); + IssueRpcService issueService = mock(IssueRpcService.class); static LanguageClientLogger lsLogOutput = mock(LanguageClientLogger.class); static SonarLintExtendedLanguageClient client = mock(SonarLintExtendedLanguageClient.class); static BackendService underTest = new BackendService(backend, lsLogOutput, client); @@ -68,6 +75,7 @@ void init() { when(backend.getConfigurationService()).thenReturn(configurationService); when(backend.getBindingService()).thenReturn(bindingRpcService); when(backend.getConnectionService()).thenReturn(connectionRpcService); + when(backend.getIssueService()).thenReturn(issueService); } @Test @@ -131,4 +139,17 @@ void shouldListUserOrganizations() { assertThat(argumentCaptor.getValue().getCredentials().getLeft().getToken()).isEqualTo(token); } + @Test + void shouldAddIssueComment() { + var issueId = UUID.randomUUID(); + when(issueService.addComment(any())).thenReturn(CompletableFuture.failedFuture(new IssueNotFoundException("Could not find issue", issueId))); + + underTest.addIssueComment(new AddIssueCommentParams("configScope", issueId.toString(), "comment")); + + var messageParamsCaptor = ArgumentCaptor.forClass(MessageParams.class); + + verify(client).showMessage(messageParamsCaptor.capture()); + assertThat(messageParamsCaptor.getValue().getMessage()).contains("Could not add a new issue comment. Look at the SonarQube for IDE output for details."); + assertThat(messageParamsCaptor.getValue().getType()).isEqualTo(MessageType.Error); + } } diff --git a/src/test/java/org/sonarsource/sonarlint/ls/clientapi/SonarLintVSCodeClientTests.java b/src/test/java/org/sonarsource/sonarlint/ls/clientapi/SonarLintVSCodeClientTests.java index 109450fa8..eddef3b17 100644 --- a/src/test/java/org/sonarsource/sonarlint/ls/clientapi/SonarLintVSCodeClientTests.java +++ b/src/test/java/org/sonarsource/sonarlint/ls/clientapi/SonarLintVSCodeClientTests.java @@ -536,7 +536,7 @@ void testNoBindingSuggestionFound() { var projectKey = "projectKey"; var messageRequestParams = new ShowMessageRequestParams(); - messageRequestParams.setMessage("SonarLint couldn't match the server project '" + projectKey + "' to any of the currently open workspace folders. Please make sure the project is open in the workspace, or try configuring the binding manually."); + messageRequestParams.setMessage("SonarQube for VS Code couldn't match the server project '" + projectKey + "' to any of the currently open workspace folders. Please make sure the project is open in the workspace, or try configuring the binding manually."); messageRequestParams.setType(MessageType.Error); var learnMoreAction = new MessageActionItem("Learn more"); messageRequestParams.setActions(List.of(learnMoreAction)); diff --git a/src/test/java/org/sonarsource/sonarlint/ls/connected/notifications/SmartNotificationsTests.java b/src/test/java/org/sonarsource/sonarlint/ls/connected/notifications/SmartNotificationsTests.java index c55bd5589..f98d0ebcf 100644 --- a/src/test/java/org/sonarsource/sonarlint/ls/connected/notifications/SmartNotificationsTests.java +++ b/src/test/java/org/sonarsource/sonarlint/ls/connected/notifications/SmartNotificationsTests.java @@ -109,7 +109,7 @@ void shouldShowSonarCloudNotificationToUserAndNotClickOnNotification() { var link = "http://some.link"; var showNotificationParams = new ShowSmartNotificationParams(message, link, Set.of(), category, "testConnection"); - var browseAction = new MessageActionItem("Show on SonarCloud"); + var browseAction = new MessageActionItem("Show on SonarQube Cloud"); when(client.showMessageRequest(any())).thenReturn(CompletableFuture.completedFuture(null)); var settingsAction = new MessageActionItem("Open Settings"); diff --git a/src/test/java/org/sonarsource/sonarlint/ls/mediumtests/AbstractLanguageServerMediumTests.java b/src/test/java/org/sonarsource/sonarlint/ls/mediumtests/AbstractLanguageServerMediumTests.java index f85442cfb..12a097f86 100644 --- a/src/test/java/org/sonarsource/sonarlint/ls/mediumtests/AbstractLanguageServerMediumTests.java +++ b/src/test/java/org/sonarsource/sonarlint/ls/mediumtests/AbstractLanguageServerMediumTests.java @@ -225,7 +225,7 @@ private static InitializeParams getInitializeParams(Map initiali var actualInitOptions = new HashMap<>(initializeOptions); if (initializeOptions.containsKey("additionalAttributes")) { - var additionalAttributes = new HashMap<>((Map)initializeOptions.get("additionalAttributes")); + var additionalAttributes = new HashMap<>((Map) initializeOptions.get("additionalAttributes")); additionalAttributes.put("csharpOssPath", CSHARP_OSS_PATH); additionalAttributes.put("csharpEnterprisePath", CSHARP_ENTERPRISE_PATH); actualInitOptions.put("additionalAttributes", additionalAttributes); @@ -411,6 +411,10 @@ public void showMessage(MessageParams messageParams) { shownMessages.add(messageParams); } + public Set getShownMessages() { + return shownMessages; + } + @Override public CompletableFuture showMessageRequest(ShowMessageRequestParams requestParams) { return CompletableFuture.completedFuture(null); diff --git a/src/test/java/org/sonarsource/sonarlint/ls/mediumtests/CFamilyMediumTests.java b/src/test/java/org/sonarsource/sonarlint/ls/mediumtests/CFamilyMediumTests.java index 8f2114bde..b5a52f93c 100644 --- a/src/test/java/org/sonarsource/sonarlint/ls/mediumtests/CFamilyMediumTests.java +++ b/src/test/java/org/sonarsource/sonarlint/ls/mediumtests/CFamilyMediumTests.java @@ -97,7 +97,7 @@ int main() { awaitUntilAsserted(() -> assertThat(client.getDiagnostics(cppFileUri)) .extracting(startLine(), startCharacter(), endLine(), endCharacter(), code(), Diagnostic::getSource, Diagnostic::getMessage, Diagnostic::getSeverity) - .containsExactlyInAnyOrder(tuple(1, 8, 1, 9, "cpp:S1481", "sonarlint", "unused variable 'i'", Warning))); + .containsExactlyInAnyOrder(tuple(1, 8, 1, 9, "cpp:S1481", "sonarqube", "unused variable 'i'", Warning))); assertThat(client.needCompilationDatabaseCalls.get()).isZero(); } @@ -175,7 +175,7 @@ int main() { awaitUntilAsserted(() -> assertThat(client.getDiagnostics(cppFileUri)) .extracting(startLine(), startCharacter(), endLine(), endCharacter(), code(), Diagnostic::getSource, Diagnostic::getMessage, Diagnostic::getSeverity) - .containsExactlyInAnyOrder(tuple(1, 8, 1, 9, "cpp:S1481", "sonarlint", "unused variable 'i'", Warning))); + .containsExactlyInAnyOrder(tuple(1, 8, 1, 9, "cpp:S1481", "sonarqube", "unused variable 'i'", Warning))); assertThat(client.needCompilationDatabaseCalls.get()).isEqualTo(1); diff --git a/src/test/java/org/sonarsource/sonarlint/ls/mediumtests/ConnectedModeMediumTests.java b/src/test/java/org/sonarsource/sonarlint/ls/mediumtests/ConnectedModeMediumTests.java index 82805a9eb..0604a7fd6 100644 --- a/src/test/java/org/sonarsource/sonarlint/ls/mediumtests/ConnectedModeMediumTests.java +++ b/src/test/java/org/sonarsource/sonarlint/ls/mediumtests/ConnectedModeMediumTests.java @@ -316,7 +316,7 @@ void analysisConnected_find_hotspot() { .extracting(startLine(), startCharacter(), endLine(), endCharacter(), code(), Diagnostic::getSource, Diagnostic::getMessage, Diagnostic::getSeverity) .containsExactly( - tuple(0, 13, 0, 26, PYTHON_S1313, "sonarlint", "Make sure using this hardcoded IP address \"12.34.56.78\" is safe here.", + tuple(0, 13, 0, 26, PYTHON_S1313, "sonarqube", "Make sure using this hardcoded IP address \"12.34.56.78\" is safe here.", DiagnosticSeverity.Warning))); } @@ -511,7 +511,7 @@ void analysisConnected_scan_all_hotspot_then_forget() throws IOException { .extracting(startLine(), startCharacter(), endLine(), endCharacter(), code(), Diagnostic::getSource, Diagnostic::getMessage, Diagnostic::getSeverity) .containsExactly( - tuple(1, 15, 1, 28, PYTHON_S1313, "sonarlint", "Make sure using this hardcoded IP address \"12.34.56.78\" is safe here.", + tuple(1, 15, 1, 28, PYTHON_S1313, "sonarqube", "Make sure using this hardcoded IP address \"12.34.56.78\" is safe here.", DiagnosticSeverity.Warning)); assertThat(client.getDiagnostics(uri1InFolder)).isEmpty(); @@ -519,7 +519,7 @@ void analysisConnected_scan_all_hotspot_then_forget() throws IOException { .extracting(startLine(), startCharacter(), endLine(), endCharacter(), code(), Diagnostic::getSource, Diagnostic::getMessage, Diagnostic::getSeverity) .containsExactly( - tuple(1, 15, 1, 28, PYTHON_S1313, "sonarlint", "Make sure using this hardcoded IP address \"23.45.67.89\" is safe here.", + tuple(1, 15, 1, 28, PYTHON_S1313, "sonarqube", "Make sure using this hardcoded IP address \"23.45.67.89\" is safe here.", DiagnosticSeverity.Warning)); assertThat(client.getDiagnostics(uri2InFolder)).isEmpty(); }); @@ -537,7 +537,7 @@ void analysisConnected_scan_all_hotspot_then_forget() throws IOException { .extracting(startLine(), startCharacter(), endLine(), endCharacter(), code(), Diagnostic::getSource, Diagnostic::getMessage, Diagnostic::getSeverity) .containsExactly( - tuple(1, 15, 1, 28, PYTHON_S1313, "sonarlint", "Make sure using this hardcoded IP address \"12.34.56.78\" is safe here.", + tuple(1, 15, 1, 28, PYTHON_S1313, "sonarqube", "Make sure using this hardcoded IP address \"12.34.56.78\" is safe here.", DiagnosticSeverity.Warning)); // File 2 is not open, cleaning hotspots @@ -571,8 +571,8 @@ void analysisConnected_no_matching_server_issues() { .extracting(startLine(), startCharacter(), endLine(), endCharacter(), code(), Diagnostic::getSource, Diagnostic::getMessage, Diagnostic::getSeverity) .containsExactlyInAnyOrder( - tuple(1, 2, 1, 6, PYTHON_S1481, "sonarlint", "Remove the unused local variable \"toto\".", DiagnosticSeverity.Warning), - tuple(2, 2, 2, 7, PYTHON_S1481, "sonarlint", "Remove the unused local variable \"plouf\".", DiagnosticSeverity.Warning))); + tuple(1, 2, 1, 6, PYTHON_S1481, "sonarqube", "Remove the unused local variable \"toto\".", DiagnosticSeverity.Warning), + tuple(2, 2, 2, 7, PYTHON_S1481, "sonarqube", "Remove the unused local variable \"plouf\".", DiagnosticSeverity.Warning))); } private void addConfigScope(String configScopeId) { @@ -625,8 +625,8 @@ void analysisConnected_matching_server_issues() throws Exception { .extracting(startLine(), startCharacter(), endLine(), endCharacter(), code(), Diagnostic::getSource, Diagnostic::getMessage, Diagnostic::getSeverity) .containsExactlyInAnyOrder( - tuple(1, 2, 1, 6, PYTHON_S1481, "sonarlint", "Remove the unused local variable \"toto\".", DiagnosticSeverity.Warning), - tuple(2, 2, 2, 7, PYTHON_S1481, "sonarlint", "Remove the unused local variable \"plouf\".", DiagnosticSeverity.Warning))); + tuple(1, 2, 1, 6, PYTHON_S1481, "sonarqube", "Remove the unused local variable \"toto\".", DiagnosticSeverity.Warning), + tuple(2, 2, 2, 7, PYTHON_S1481, "sonarqube", "Remove the unused local variable \"plouf\".", DiagnosticSeverity.Warning))); var firstDiagnostic = client.getDiagnostics(uriInFolder).get(0); var codeActionParams = new CodeActionParams(); @@ -834,8 +834,8 @@ void shouldChangeIssueStatus() { .extracting(startLine(), startCharacter(), endLine(), endCharacter(), code(), Diagnostic::getSource, Diagnostic::getMessage, Diagnostic::getSeverity) .containsExactlyInAnyOrder( - tuple(1, 2, 1, 6, PYTHON_S1481, "sonarlint", "Remove the unused local variable \"toto\".", DiagnosticSeverity.Warning), - tuple(2, 2, 2, 7, PYTHON_S1481, "sonarlint", "Remove the unused local variable \"plouf\".", DiagnosticSeverity.Warning))); + tuple(1, 2, 1, 6, PYTHON_S1481, "sonarqube", "Remove the unused local variable \"toto\".", DiagnosticSeverity.Warning), + tuple(2, 2, 2, 7, PYTHON_S1481, "sonarqube", "Remove the unused local variable \"plouf\".", DiagnosticSeverity.Warning))); lsProxy.changeIssueStatus(new SonarLintExtendedLanguageServer.ChangeIssueStatusParams(folder1BaseDir.toUri().toString(), issueKey, "False positive", fileUri, "clever comment", false)); @@ -845,10 +845,43 @@ void shouldChangeIssueStatus() { .extracting(startLine(), startCharacter(), endLine(), endCharacter(), code(), Diagnostic::getSource, Diagnostic::getMessage, Diagnostic::getSeverity) .containsExactlyInAnyOrder( - tuple(2, 2, 2, 7, PYTHON_S1481, "sonarlint", "Remove the unused local variable \"plouf\".", DiagnosticSeverity.Warning))); + tuple(2, 2, 2, 7, PYTHON_S1481, "sonarqube", "Remove the unused local variable \"plouf\".", DiagnosticSeverity.Warning))); assertThat(client.shownMessages).contains(new MessageParams(MessageType.Info, "New comment was added")); } + @Test + void shouldNotChangeIssueStatus() { + var issueKey = "xyz"; + + mockWebServerExtension.addResponse("/api/issues/do_transition", new MockResponse().setResponseCode(400)); + mockWebServerExtension.addResponse("/api/issues/add_comment", new MockResponse().setResponseCode(400)); + mockWebServerExtension.addProtobufResponse( + "/api/hotspots/search.protobuf?projectKey=myProject&files=inFolderToo.py&branch=master&ps=500&p=1", + Hotspots.SearchWsResponse.newBuilder().build()); + + addConfigScope(folder1BaseDir.toUri().toString()); + awaitUntilAsserted(() -> assertThat(client.logs.stream().anyMatch(messageParams -> messageParams.getMessage().contains("Synchronizing project branches for project 'myProject'"))).isTrue()); + lsProxy.didLocalBranchNameChange(new SonarLintExtendedLanguageServer.DidLocalBranchNameChangeParams(folder1BaseDir.toUri().toString(), "some/branch/name")); + + var fileUri = folder1BaseDir.resolve("inFolderToo.py").toUri().toString(); + var content = "def foo():\n toto = 0\n plouf = 0\n"; + didOpen(fileUri, "python", content); + + awaitUntilAsserted(() -> assertThat(client.getDiagnostics(fileUri)) + .extracting(startLine(), startCharacter(), endLine(), endCharacter(), code(), Diagnostic::getSource, Diagnostic::getMessage, + Diagnostic::getSeverity) + .containsExactlyInAnyOrder( + tuple(1, 2, 1, 6, PYTHON_S1481, "sonarqube", "Remove the unused local variable \"toto\".", DiagnosticSeverity.Warning), + tuple(2, 2, 2, 7, PYTHON_S1481, "sonarqube", "Remove the unused local variable \"plouf\".", DiagnosticSeverity.Warning))); + + lsProxy.changeIssueStatus(new SonarLintExtendedLanguageServer.ChangeIssueStatusParams(folder1BaseDir.toUri().toString(), issueKey, + "False positive", fileUri, "clever comment", false)); + + //Now we expect that one issue is resolved + awaitUntilAsserted(() -> assertThat(client.shownMessages) + .contains(new MessageParams(MessageType.Error, "Could not change status for the issue. Look at the SonarQube for IDE output for details."))); + } + @Test void change_hotspot_status_to_resolved() { var analyzedFileName = "hotspot_resolved.py"; @@ -931,6 +964,88 @@ void change_hotspot_status_to_resolved() { awaitUntilAsserted(() -> assertThat(client.getHotspots(uriInFolder)).isEmpty()); } + @Test + void should_not_change_hotspot_status_to_resolved() { + var analyzedFileName = "hotspot_not_resolved.py"; + + mockWebServerExtension.addStringResponse("/api/system/status", "{\"status\": \"UP\", \"version\": \"10.1\", \"id\": \"xzy\"}"); + mockWebServerExtension.addResponse("/api/hotspots/change_status", new MockResponse().setResponseCode(400)); + mockNoIssueAndNoTaintInIncrementalSync(); + mockWebServerExtension.addProtobufResponse( + "/api/hotspots/search.protobuf?projectKey=myProject&files=" + analyzedFileName + "&branch=master&ps=500&p=1", + Hotspots.SearchWsResponse.newBuilder().build()); + mockWebServerExtension.addProtobufResponse( + "/api/rules/show.protobuf?key=python:S1313", + Rules.ShowResponse.newBuilder() + .setRule(Rules.Rule.newBuilder() + .setSeverity("MINOR") + .setType(Common.RuleType.SECURITY_HOTSPOT) + .setLang(SonarLanguage.PYTHON.getSonarLanguageKey()) + .build()) + .build()); + var hotspotKey = "myhotspotkey"; + mockWebServerExtension.addProtobufResponseDelimited( + "/api/hotspots/pull?projectKey=myProject&branchName=master&languages=" + LANGUAGES_LIST, + Hotspots.HotspotPullQueryTimestamp.newBuilder().setQueryTimestamp(CURRENT_TIME).build(), + Hotspots.HotspotLite.newBuilder() + .setKey(hotspotKey) + .setFilePath(analyzedFileName) + .setCreationDate(System.currentTimeMillis()) + .setStatus("TO_REVIEW") + .setVulnerabilityProbability("LOW") + .setMessage("Make sure using this hardcoded IP address \"12.34.56.78\" is safe here.") + .setTextRange(Hotspots.TextRange.newBuilder() + .setStartLine(1) + .setStartLineOffset(13) + .setEndLine(1) + .setEndLineOffset(26) + .setHash(Utils.hash("'12.34.56.78'")) + .build() + ) + .setRuleKey(PYTHON_S1313) + .build() + ); + mockWebServerExtension.addProtobufResponseDelimited( + "/api/hotspots/pull?projectKey=myProject&branchName=master&languages=" + LANGUAGES_LIST + "&changedSince=" + CURRENT_TIME, + Hotspots.HotspotPullQueryTimestamp.newBuilder().setQueryTimestamp(CURRENT_TIME).build(), + Hotspots.HotspotLite.newBuilder() + .setKey(hotspotKey) + .setFilePath(analyzedFileName) + .setCreationDate(System.currentTimeMillis()) + .setStatus("TO_REVIEW") + .setVulnerabilityProbability("LOW") + .setMessage("Make sure using this hardcoded IP address \"12.34.56.78\" is safe here.") + .setTextRange(Hotspots.TextRange.newBuilder() + .setStartLine(1) + .setStartLineOffset(13) + .setEndLine(1) + .setEndLineOffset(26) + .setHash(Utils.hash("'12.34.56.78'")) + .build() + ) + .setRuleKey(PYTHON_S1313) + .build() + ); + + + var uriInFolder = folder1BaseDir.resolve(analyzedFileName).toUri().toString(); + addConfigScope(folder1BaseDir.toUri().toString()); + awaitUntilAsserted(() -> assertThat(client.logs).anyMatch(messageParams -> messageParams.getMessage().contains("Merged 1 hotspots in store. Closed 0."))); + lsProxy.didLocalBranchNameChange(new SonarLintExtendedLanguageServer.DidLocalBranchNameChangeParams(folder1BaseDir.toUri().toString(), "master")); + + didOpen(uriInFolder, "python", "IP_ADDRESS = '12.34.56.78'\n"); + + awaitUntilAsserted(() -> assertThat(client.getHotspots(uriInFolder)) + .extracting(startLine(), startCharacter(), endLine(), endCharacter(), code(), Diagnostic::getSource, Diagnostic::getMessage, Diagnostic::getSeverity) + .containsExactly( + tuple(0, 13, 0, 26, PYTHON_S1313, "remote", "Make sure using this hardcoded IP address \"12.34.56.78\" is safe here.", DiagnosticSeverity.Warning))); + assertThat(client.getHotspots(uriInFolder).get(0).getData().toString()).contains("\"status\":0"); + + lsProxy.changeHotspotStatus(new SonarLintExtendedLanguageServer.ChangeHotspotStatusParams(hotspotKey, HotspotStatus.SAFE.name(), uriInFolder)); + + awaitUntilAsserted(() -> assertThat(client.shownMessages).contains(new MessageParams(MessageType.Error, "Could not change status for the hotspot. Look at the SonarQube for IDE output for details."))); + } + @Test void change_hotspot_status_permission_check() throws ExecutionException, InterruptedException { var analyzedFileName = "hotspot_permissions.py"; @@ -1028,6 +1143,29 @@ void change_hotspot_status_permission_check() throws ExecutionException, Interru assertThat(response.getAllowedStatuses()).containsExactly("ACKNOWLEDGED", "FIXED", "SAFE"); } + @Test + void change_hotspot_status_permission_check_fail() throws ExecutionException, InterruptedException { + var analyzedFileName = "hotspot_no_permissions.py"; + mockWebServerExtension.addStringResponse("/api/system/status", "{\"status\": \"UP\", \"version\": \"10.1\", \"id\": \"xzy\"}"); + mockWebServerExtension.addResponse("/api/hotspots/change_status", new MockResponse().setResponseCode(400)); + + var uriInFolder = folder1BaseDir.resolve(analyzedFileName).toUri().toString(); + addConfigScope(folder1BaseDir.toUri().toString()); + var hotspotKey = "myHotspotKey"; + + didOpen(uriInFolder, "python", "IP_ADDRESS = '12.34.56.78'\n"); + + awaitUntilAsserted(() -> assertThat(client.getHotspots(uriInFolder)) + .extracting(startLine(), startCharacter(), endLine(), endCharacter(), code(), Diagnostic::getSource, Diagnostic::getMessage, Diagnostic::getSeverity) + .containsExactly( + tuple(0, 13, 0, 26, PYTHON_S1313, "sonarqube", "Make sure using this hardcoded IP address \"12.34.56.78\" is safe here.", DiagnosticSeverity.Warning))); + + lsProxy.getAllowedHotspotStatuses( + new SonarLintExtendedLanguageServer.GetAllowedHotspotStatusesParams(hotspotKey, folder1BaseDir.toUri().toString(), uriInFolder)).get(); + + awaitUntilAsserted(() -> assertThat(client.shownMessages).contains(new MessageParams(MessageType.Error, "Could not change status for the hotspot. Look at the SonarQube for IDE output for details."))); + } + @Test void change_issue_status_permission_check() throws ExecutionException, InterruptedException { var issueKey = UUID.randomUUID().toString(); @@ -1054,8 +1192,8 @@ void change_issue_status_permission_check() throws ExecutionException, Interrupt .extracting(startLine(), startCharacter(), endLine(), endCharacter(), code(), Diagnostic::getSource, Diagnostic::getMessage, Diagnostic::getSeverity) .containsExactlyInAnyOrder( - tuple(1, 2, 1, 6, PYTHON_S1481, "sonarlint", "Remove the unused local variable \"toto\".", DiagnosticSeverity.Warning), - tuple(2, 2, 2, 7, PYTHON_S1481, "sonarlint", "Remove the unused local variable \"plouf\".", DiagnosticSeverity.Warning))); + tuple(1, 2, 1, 6, PYTHON_S1481, "sonarqube", "Remove the unused local variable \"toto\".", DiagnosticSeverity.Warning), + tuple(2, 2, 2, 7, PYTHON_S1481, "sonarqube", "Remove the unused local variable \"plouf\".", DiagnosticSeverity.Warning))); var result = lsProxy.checkIssueStatusChangePermitted(new SonarLintExtendedLanguageServer.CheckIssueStatusChangePermittedParams(folder1BaseDir.toUri().toString(), issueKey)).get(); @@ -1079,7 +1217,7 @@ void change_issue_status_permission_check_exceptionally() throws ExecutionExcept assertThat(client.logs) .extracting(withoutTimestamp()) .contains("Could not get issue status change for issue \"" - + issueKey + "\". Look at the SonarLint output for details."); + + issueKey + "\". Look at the SonarQube for IDE output for details."); }); } @@ -1155,8 +1293,8 @@ void shouldReopenResolvedLocalIssues() throws URISyntaxException { .extracting(startLine(), startCharacter(), endLine(), endCharacter(), code(), Diagnostic::getSource, Diagnostic::getMessage, Diagnostic::getSeverity) .containsExactlyInAnyOrder( - tuple(1, 2, 1, 6, PYTHON_S1481, "sonarlint", "Remove the unused local variable \"toto\".", DiagnosticSeverity.Warning), - tuple(2, 2, 2, 7, PYTHON_S1481, "sonarlint", "Remove the unused local variable \"plouf\".", DiagnosticSeverity.Warning))); + tuple(1, 2, 1, 6, PYTHON_S1481, "sonarqube", "Remove the unused local variable \"toto\".", DiagnosticSeverity.Warning), + tuple(2, 2, 2, 7, PYTHON_S1481, "sonarqube", "Remove the unused local variable \"plouf\".", DiagnosticSeverity.Warning))); } @Test @@ -1188,8 +1326,8 @@ private void assertLocalIssuesStatusChanged(String fileUri) throws URISyntaxExce .extracting(startLine(), startCharacter(), endLine(), endCharacter(), code(), Diagnostic::getSource, Diagnostic::getMessage, Diagnostic::getSeverity) .containsExactlyInAnyOrder( - tuple(1, 2, 1, 6, PYTHON_S1481, "sonarlint", "Remove the unused local variable \"toto\".", DiagnosticSeverity.Warning), - tuple(2, 2, 2, 7, PYTHON_S1481, "sonarlint", "Remove the unused local variable \"plouf\".", DiagnosticSeverity.Warning))); + tuple(1, 2, 1, 6, PYTHON_S1481, "sonarqube", "Remove the unused local variable \"toto\".", DiagnosticSeverity.Warning), + tuple(2, 2, 2, 7, PYTHON_S1481, "sonarqube", "Remove the unused local variable \"plouf\".", DiagnosticSeverity.Warning))); var diagnostics = client.getDiagnostics(fileUri); var issueKey = ((JsonObject) diagnostics.stream().filter(it -> it.getMessage().equals("Remove the unused local variable \"plouf\".")) @@ -1202,7 +1340,7 @@ private void assertLocalIssuesStatusChanged(String fileUri) throws URISyntaxExce .extracting(startLine(), startCharacter(), endLine(), endCharacter(), code(), Diagnostic::getSource, Diagnostic::getMessage, Diagnostic::getSeverity) .containsExactlyInAnyOrder( - tuple(1, 2, 1, 6, PYTHON_S1481, "sonarlint", "Remove the unused local variable \"toto\".", DiagnosticSeverity.Warning))); + tuple(1, 2, 1, 6, PYTHON_S1481, "sonarqube", "Remove the unused local variable \"toto\".", DiagnosticSeverity.Warning))); } private String getFileNameFromFileUri(String fileUri) throws URISyntaxException { diff --git a/src/test/java/org/sonarsource/sonarlint/ls/mediumtests/JavaMediumTests.java b/src/test/java/org/sonarsource/sonarlint/ls/mediumtests/JavaMediumTests.java index bed7f63e5..e2c0ca0a8 100644 --- a/src/test/java/org/sonarsource/sonarlint/ls/mediumtests/JavaMediumTests.java +++ b/src/test/java/org/sonarsource/sonarlint/ls/mediumtests/JavaMediumTests.java @@ -105,10 +105,10 @@ void analyseJavaFilesAsNonJavaIfNoClasspath() throws Exception { awaitUntilAsserted(() -> assertThat(client.getDiagnostics(uri)) .extracting(startLine(), startCharacter(), endLine(), endCharacter(), code(), Diagnostic::getSource, Diagnostic::getMessage, Diagnostic::getSeverity) .containsExactlyInAnyOrder( - tuple(0, 13, 0, 16, "java:S1118", "sonarlint", "Add a private constructor to hide the implicit public one.", DiagnosticSeverity.Warning), - tuple(0, 0, 0, 0, "java:S1220", "sonarlint", "Move this file to a named package.", DiagnosticSeverity.Warning), - tuple(1, 46, 1, 66, "secrets:S6290", "sonarlint", "Make sure the access granted with this AWS access key ID is restricted", DiagnosticSeverity.Warning), - tuple(3, 5, 3, 31, "java:S125", "sonarlint", "This block of commented-out lines of code should be removed.", DiagnosticSeverity.Warning))); + tuple(0, 13, 0, 16, "java:S1118", "sonarqube", "Add a private constructor to hide the implicit public one.", DiagnosticSeverity.Warning), + tuple(0, 0, 0, 0, "java:S1220", "sonarqube", "Move this file to a named package.", DiagnosticSeverity.Warning), + tuple(1, 46, 1, 66, "secrets:S6290", "sonarqube", "Make sure the access granted with this AWS access key ID is restricted", DiagnosticSeverity.Warning), + tuple(3, 5, 3, 31, "java:S125", "sonarqube", "This block of commented-out lines of code should be removed.", DiagnosticSeverity.Warning))); awaitUntilAsserted(() -> assertThat(client.logs) .extracting(withoutTimestamp()) .contains( @@ -131,9 +131,9 @@ void analyzeSimpleJavaFileReuseCachedClasspath() throws Exception { awaitUntilAsserted(() -> assertThat(client.getDiagnostics(uri)) .extracting(startLine(), startCharacter(), endLine(), endCharacter(), code(), Diagnostic::getSource, Diagnostic::getMessage, Diagnostic::getSeverity) .containsExactlyInAnyOrder( - tuple(0, 13, 0, 16, "java:S1118", "sonarlint", "Add a private constructor to hide the implicit public one.", DiagnosticSeverity.Warning), - tuple(0, 0, 0, 0, "java:S1220", "sonarlint", "Move this file to a named package.", DiagnosticSeverity.Warning), - tuple(2, 5, 2, 31, "java:S125", "sonarlint", "This block of commented-out lines of code should be removed.", DiagnosticSeverity.Warning))); + tuple(0, 13, 0, 16, "java:S1118", "sonarqube", "Add a private constructor to hide the implicit public one.", DiagnosticSeverity.Warning), + tuple(0, 0, 0, 0, "java:S1220", "sonarqube", "Move this file to a named package.", DiagnosticSeverity.Warning), + tuple(2, 5, 2, 31, "java:S125", "sonarqube", "This block of commented-out lines of code should be removed.", DiagnosticSeverity.Warning))); var ignoredMsg = "[Debug] Classpath \"/does/not/exist\" from configuration does not exist, skipped"; var cacheMsg = "[Debug] Cached Java config for file \"" + uri + "\""; @@ -148,9 +148,9 @@ void analyzeSimpleJavaFileReuseCachedClasspath() throws Exception { awaitUntilAsserted(() -> assertThat(client.getDiagnostics(uri)) .extracting(startLine(), startCharacter(), endLine(), endCharacter(), code(), Diagnostic::getSource, Diagnostic::getMessage, Diagnostic::getSeverity) .containsExactlyInAnyOrder( - tuple(0, 13, 0, 16, "java:S1118", "sonarlint", "Add a private constructor to hide the implicit public one.", DiagnosticSeverity.Warning), - tuple(0, 0, 0, 0, "java:S1220", "sonarlint", "Move this file to a named package.", DiagnosticSeverity.Warning), - tuple(3, 2, 3, 12, "java:S106", "sonarlint", "Replace this use of System.out by a logger.", DiagnosticSeverity.Warning))); + tuple(0, 13, 0, 16, "java:S1118", "sonarqube", "Add a private constructor to hide the implicit public one.", DiagnosticSeverity.Warning), + tuple(0, 0, 0, 0, "java:S1220", "sonarqube", "Move this file to a named package.", DiagnosticSeverity.Warning), + tuple(3, 2, 3, 12, "java:S106", "sonarqube", "Replace this use of System.out by a logger.", DiagnosticSeverity.Warning))); assertThat(client.logs).extracting(withoutTimestamp()).doesNotContain(cacheMsg); } @@ -184,9 +184,9 @@ void analyzeSimpleJavaFileWithFlows() throws Exception { awaitUntilAsserted(() -> assertThat(client.getDiagnostics(uri)) .extracting(startLine(), startCharacter(), endLine(), endCharacter(), code(), Diagnostic::getSource, Diagnostic::getMessage, Diagnostic::getSeverity) .containsExactlyInAnyOrder( - tuple(7, 11, 7, 26, "java:S2259", "sonarlint", "\"NullPointerException\" will be thrown when invoking method \"doSomeThingWith()\". [+5 locations]", + tuple(7, 11, 7, 26, "java:S2259", "sonarqube", "\"NullPointerException\" will be thrown when invoking method \"doSomeThingWith()\". [+5 locations]", DiagnosticSeverity.Warning), - tuple(0, 0, 0, 0, "java:S1220", "sonarlint", "Move this file to a named package.", DiagnosticSeverity.Warning))); + tuple(0, 0, 0, 0, "java:S1220", "sonarqube", "Move this file to a named package.", DiagnosticSeverity.Warning))); } @Test @@ -213,9 +213,9 @@ void analyzeSimpleJavaFilePassVmClasspath() throws Exception { awaitUntilAsserted(() -> assertThat(client.getDiagnostics(uri)) .extracting(startLine(), startCharacter(), endLine(), endCharacter(), code(), Diagnostic::getSource, Diagnostic::getMessage, Diagnostic::getSeverity) .containsExactlyInAnyOrder( - tuple(0, 13, 0, 16, "java:S1118", "sonarlint", "Add a private constructor to hide the implicit public one.", DiagnosticSeverity.Warning), - tuple(0, 0, 0, 0, "java:S1220", "sonarlint", "Move this file to a named package.", DiagnosticSeverity.Warning), - tuple(2, 5, 2, 31, "java:S125", "sonarlint", "This block of commented-out lines of code should be removed.", DiagnosticSeverity.Warning))); + tuple(0, 13, 0, 16, "java:S1118", "sonarqube", "Add a private constructor to hide the implicit public one.", DiagnosticSeverity.Warning), + tuple(0, 0, 0, 0, "java:S1220", "sonarqube", "Move this file to a named package.", DiagnosticSeverity.Warning), + tuple(2, 5, 2, 31, "java:S125", "sonarqube", "This block of commented-out lines of code should be removed.", DiagnosticSeverity.Warning))); var jrtFsJarPath = currentJdkHome.resolve(isModular ? "lib/jrt-fs.jar" : "jre/lib/rt.jar").toString(); assertThat(client.logs) @@ -243,7 +243,7 @@ void analyzeSimpleJavaTestFileOnOpen() throws Exception { awaitUntilAsserted(() -> assertThat(client.getDiagnostics(uri)) .extracting(startLine(), startCharacter(), endLine(), endCharacter(), code(), Diagnostic::getSource, Diagnostic::getMessage, Diagnostic::getSeverity) .containsExactlyInAnyOrder( - tuple(3, 14, 3, 18, "java:S2699", "sonarlint", "Add at least one assertion to this test case.", DiagnosticSeverity.Warning))); + tuple(3, 14, 3, 18, "java:S2699", "sonarqube", "Add at least one assertion to this test case.", DiagnosticSeverity.Warning))); } @Test @@ -280,7 +280,7 @@ void testClassPathUpdateEvictCacheAndTriggersNewAnalysis(@TempDir Path projectRo awaitUntilAsserted(() -> assertThat(client.getDiagnostics(uri)) .extracting(startLine(), startCharacter(), endLine(), endCharacter(), code(), Diagnostic::getSource, Diagnostic::getMessage, Diagnostic::getSeverity) .containsExactlyInAnyOrder( - tuple(3, 14, 3, 18, "java:S2699", "sonarlint", "Add at least one assertion to this test case.", DiagnosticSeverity.Warning))); + tuple(3, 14, 3, 18, "java:S2699", "sonarqube", "Add at least one assertion to this test case.", DiagnosticSeverity.Warning))); assertThat(client.logs) .extracting(withoutTimestamp()) @@ -304,9 +304,9 @@ void testJavaServerModeUpdateToStandardTriggersNewAnalysis() throws Exception { awaitUntilAsserted(() -> assertThat(client.getDiagnostics(uri)) .extracting(startLine(), startCharacter(), endLine(), endCharacter(), code(), Diagnostic::getSource, Diagnostic::getMessage, Diagnostic::getSeverity) .containsExactlyInAnyOrder( - tuple(0, 13, 0, 16, "java:S1118", "sonarlint", "Add a private constructor to hide the implicit public one.", DiagnosticSeverity.Warning), - tuple(0, 0, 0, 0, "java:S1220", "sonarlint", "Move this file to a named package.", DiagnosticSeverity.Warning), - tuple(2, 5, 2, 31, "java:S125", "sonarlint", "This block of commented-out lines of code should be removed.", DiagnosticSeverity.Warning))); + tuple(0, 13, 0, 16, "java:S1118", "sonarqube", "Add a private constructor to hide the implicit public one.", DiagnosticSeverity.Warning), + tuple(0, 0, 0, 0, "java:S1220", "sonarqube", "Move this file to a named package.", DiagnosticSeverity.Warning), + tuple(2, 5, 2, 31, "java:S125", "sonarqube", "This block of commented-out lines of code should be removed.", DiagnosticSeverity.Warning))); // Prepare config response var javaConfigResponse = new GetJavaConfigResponse(); @@ -323,9 +323,9 @@ void testJavaServerModeUpdateToStandardTriggersNewAnalysis() throws Exception { awaitUntilAsserted(() -> assertThat(client.getDiagnostics(uri)) .extracting(startLine(), startCharacter(), endLine(), endCharacter(), code(), Diagnostic::getSource, Diagnostic::getMessage, Diagnostic::getSeverity) .containsExactlyInAnyOrder( - tuple(0, 13, 0, 16, "java:S1118", "sonarlint", "Add a private constructor to hide the implicit public one.", DiagnosticSeverity.Warning), - tuple(0, 0, 0, 0, "java:S1220", "sonarlint", "Move this file to a named package.", DiagnosticSeverity.Warning), - tuple(2, 5, 2, 31, "java:S125", "sonarlint", "This block of commented-out lines of code should be removed.", DiagnosticSeverity.Warning))); + tuple(0, 13, 0, 16, "java:S1118", "sonarqube", "Add a private constructor to hide the implicit public one.", DiagnosticSeverity.Warning), + tuple(0, 0, 0, 0, "java:S1220", "sonarqube", "Move this file to a named package.", DiagnosticSeverity.Warning), + tuple(2, 5, 2, 31, "java:S125", "sonarqube", "This block of commented-out lines of code should be removed.", DiagnosticSeverity.Warning))); } @Test @@ -352,22 +352,22 @@ void shouldBatchAnalysisFromTheSameModule() throws Exception { assertThat(client.getDiagnostics(file1module1)) .extracting(startLine(), startCharacter(), endLine(), endCharacter(), code(), Diagnostic::getSource, Diagnostic::getMessage, Diagnostic::getSeverity) .containsExactlyInAnyOrder( - tuple(0, 13, 0, 17, "java:S1118", "sonarlint", "Add a private constructor to hide the implicit public one.", DiagnosticSeverity.Warning), - tuple(0, 0, 0, 0, "java:S1220", "sonarlint", "Move this file to a named package.", DiagnosticSeverity.Warning), - tuple(2, 5, 2, 31, "java:S125", "sonarlint", "This block of commented-out lines of code should be removed.", DiagnosticSeverity.Warning)); + tuple(0, 13, 0, 17, "java:S1118", "sonarqube", "Add a private constructor to hide the implicit public one.", DiagnosticSeverity.Warning), + tuple(0, 0, 0, 0, "java:S1220", "sonarqube", "Move this file to a named package.", DiagnosticSeverity.Warning), + tuple(2, 5, 2, 31, "java:S125", "sonarqube", "This block of commented-out lines of code should be removed.", DiagnosticSeverity.Warning)); assertThat(client.getDiagnostics(file2module1)) .extracting(startLine(), startCharacter(), endLine(), endCharacter(), code(), Diagnostic::getSource, Diagnostic::getMessage, Diagnostic::getSeverity) .containsExactlyInAnyOrder( - tuple(0, 13, 0, 17, "java:S1118", "sonarlint", "Add a private constructor to hide the implicit public one.", DiagnosticSeverity.Warning), - tuple(0, 0, 0, 0, "java:S1220", "sonarlint", "Move this file to a named package.", DiagnosticSeverity.Warning), - tuple(2, 5, 2, 31, "java:S125", "sonarlint", "This block of commented-out lines of code should be removed.", DiagnosticSeverity.Warning)); + tuple(0, 13, 0, 17, "java:S1118", "sonarqube", "Add a private constructor to hide the implicit public one.", DiagnosticSeverity.Warning), + tuple(0, 0, 0, 0, "java:S1220", "sonarqube", "Move this file to a named package.", DiagnosticSeverity.Warning), + tuple(2, 5, 2, 31, "java:S125", "sonarqube", "This block of commented-out lines of code should be removed.", DiagnosticSeverity.Warning)); assertThat(client.getDiagnostics(nonJavaFilemodule1)) .extracting(startLine(), startCharacter(), endLine(), endCharacter(), code(), Diagnostic::getSource, Diagnostic::getMessage, Diagnostic::getSeverity) .containsExactlyInAnyOrder( - tuple(1, 2, 1, 6, "python:S1481", "sonarlint", "Remove the unused local variable \"toto\".", DiagnosticSeverity.Warning), - tuple(2, 2, 2, 7, "python:S1481", "sonarlint", "Remove the unused local variable \"plouf\".", DiagnosticSeverity.Warning)); + tuple(1, 2, 1, 6, "python:S1481", "sonarqube", "Remove the unused local variable \"toto\".", DiagnosticSeverity.Warning), + tuple(2, 2, 2, 7, "python:S1481", "sonarqube", "Remove the unused local variable \"plouf\".", DiagnosticSeverity.Warning)); }); // consecutive changes should be batched @@ -385,22 +385,22 @@ void shouldBatchAnalysisFromTheSameModule() throws Exception { assertThat(client.getDiagnostics(file1module1)) .extracting(startLine(), startCharacter(), endLine(), endCharacter(), code(), Diagnostic::getSource, Diagnostic::getMessage, Diagnostic::getSeverity) .containsExactlyInAnyOrder( - tuple(0, 13, 0, 17, "java:S1118", "sonarlint", "Add a private constructor to hide the implicit public one.", DiagnosticSeverity.Warning), - tuple(0, 0, 0, 0, "java:S1220", "sonarlint", "Move this file to a named package.", DiagnosticSeverity.Warning), - tuple(2, 5, 2, 31, "java:S125", "sonarlint", "This block of commented-out lines of code should be removed.", DiagnosticSeverity.Warning)); + tuple(0, 13, 0, 17, "java:S1118", "sonarqube", "Add a private constructor to hide the implicit public one.", DiagnosticSeverity.Warning), + tuple(0, 0, 0, 0, "java:S1220", "sonarqube", "Move this file to a named package.", DiagnosticSeverity.Warning), + tuple(2, 5, 2, 31, "java:S125", "sonarqube", "This block of commented-out lines of code should be removed.", DiagnosticSeverity.Warning)); assertThat(client.getDiagnostics(file2module1)) .extracting(startLine(), startCharacter(), endLine(), endCharacter(), code(), Diagnostic::getSource, Diagnostic::getMessage, Diagnostic::getSeverity) .containsExactlyInAnyOrder( - tuple(0, 13, 0, 17, "java:S1118", "sonarlint", "Add a private constructor to hide the implicit public one.", DiagnosticSeverity.Warning), - tuple(0, 0, 0, 0, "java:S1220", "sonarlint", "Move this file to a named package.", DiagnosticSeverity.Warning), - tuple(2, 5, 2, 31, "java:S125", "sonarlint", "This block of commented-out lines of code should be removed.", DiagnosticSeverity.Warning)); + tuple(0, 13, 0, 17, "java:S1118", "sonarqube", "Add a private constructor to hide the implicit public one.", DiagnosticSeverity.Warning), + tuple(0, 0, 0, 0, "java:S1220", "sonarqube", "Move this file to a named package.", DiagnosticSeverity.Warning), + tuple(2, 5, 2, 31, "java:S125", "sonarqube", "This block of commented-out lines of code should be removed.", DiagnosticSeverity.Warning)); assertThat(client.getDiagnostics(nonJavaFilemodule1)) .extracting(startLine(), startCharacter(), endLine(), endCharacter(), code(), Diagnostic::getSource, Diagnostic::getMessage, Diagnostic::getSeverity) .containsExactlyInAnyOrder( - tuple(1, 2, 1, 6, "python:S1481", "sonarlint", "Remove the unused local variable \"toto\".", DiagnosticSeverity.Warning), - tuple(2, 2, 2, 7, "python:S1481", "sonarlint", "Remove the unused local variable \"plouf\".", DiagnosticSeverity.Warning)); + tuple(1, 2, 1, 6, "python:S1481", "sonarqube", "Remove the unused local variable \"toto\".", DiagnosticSeverity.Warning), + tuple(2, 2, 2, 7, "python:S1481", "sonarqube", "Remove the unused local variable \"plouf\".", DiagnosticSeverity.Warning)); }); } @@ -432,16 +432,16 @@ void shouldNotBatchAnalysisFromDifferentModules() throws Exception { assertThat(client.getDiagnostics(file1module1)) .extracting(startLine(), startCharacter(), endLine(), endCharacter(), code(), Diagnostic::getSource, Diagnostic::getMessage, Diagnostic::getSeverity) .containsExactlyInAnyOrder( - tuple(0, 13, 0, 16, "java:S1118", "sonarlint", "Add a private constructor to hide the implicit public one.", DiagnosticSeverity.Warning), - tuple(0, 0, 0, 0, "java:S1220", "sonarlint", "Move this file to a named package.", DiagnosticSeverity.Warning), - tuple(2, 5, 2, 31, "java:S125", "sonarlint", "This block of commented-out lines of code should be removed.", DiagnosticSeverity.Warning)); + tuple(0, 13, 0, 16, "java:S1118", "sonarqube", "Add a private constructor to hide the implicit public one.", DiagnosticSeverity.Warning), + tuple(0, 0, 0, 0, "java:S1220", "sonarqube", "Move this file to a named package.", DiagnosticSeverity.Warning), + tuple(2, 5, 2, 31, "java:S125", "sonarqube", "This block of commented-out lines of code should be removed.", DiagnosticSeverity.Warning)); assertThat(client.getDiagnostics(file2module2)) .extracting(startLine(), startCharacter(), endLine(), endCharacter(), code(), Diagnostic::getSource, Diagnostic::getMessage, Diagnostic::getSeverity) .containsExactlyInAnyOrder( - tuple(0, 13, 0, 16, "java:S1118", "sonarlint", "Add a private constructor to hide the implicit public one.", DiagnosticSeverity.Warning), - tuple(0, 0, 0, 0, "java:S1220", "sonarlint", "Move this file to a named package.", DiagnosticSeverity.Warning), - tuple(2, 5, 2, 31, "java:S125", "sonarlint", "This block of commented-out lines of code should be removed.", DiagnosticSeverity.Warning)); + tuple(0, 13, 0, 16, "java:S1118", "sonarqube", "Add a private constructor to hide the implicit public one.", DiagnosticSeverity.Warning), + tuple(0, 0, 0, 0, "java:S1220", "sonarqube", "Move this file to a named package.", DiagnosticSeverity.Warning), + tuple(2, 5, 2, 31, "java:S125", "sonarqube", "This block of commented-out lines of code should be removed.", DiagnosticSeverity.Warning)); }); client.logs.clear(); @@ -458,16 +458,16 @@ void shouldNotBatchAnalysisFromDifferentModules() throws Exception { assertThat(client.getDiagnostics(file1module1)) .extracting(startLine(), startCharacter(), endLine(), endCharacter(), code(), Diagnostic::getSource, Diagnostic::getMessage, Diagnostic::getSeverity) .containsExactlyInAnyOrder( - tuple(0, 13, 0, 16, "java:S1118", "sonarlint", "Add a private constructor to hide the implicit public one.", DiagnosticSeverity.Warning), - tuple(0, 0, 0, 0, "java:S1220", "sonarlint", "Move this file to a named package.", DiagnosticSeverity.Warning), - tuple(2, 5, 2, 31, "java:S125", "sonarlint", "This block of commented-out lines of code should be removed.", DiagnosticSeverity.Warning)); + tuple(0, 13, 0, 16, "java:S1118", "sonarqube", "Add a private constructor to hide the implicit public one.", DiagnosticSeverity.Warning), + tuple(0, 0, 0, 0, "java:S1220", "sonarqube", "Move this file to a named package.", DiagnosticSeverity.Warning), + tuple(2, 5, 2, 31, "java:S125", "sonarqube", "This block of commented-out lines of code should be removed.", DiagnosticSeverity.Warning)); assertThat(client.getDiagnostics(file2module2)) .extracting(startLine(), startCharacter(), endLine(), endCharacter(), code(), Diagnostic::getSource, Diagnostic::getMessage, Diagnostic::getSeverity) .containsExactlyInAnyOrder( - tuple(0, 13, 0, 16, "java:S1118", "sonarlint", "Add a private constructor to hide the implicit public one.", DiagnosticSeverity.Warning), - tuple(0, 0, 0, 0, "java:S1220", "sonarlint", "Move this file to a named package.", DiagnosticSeverity.Warning), - tuple(2, 5, 2, 31, "java:S125", "sonarlint", "This block of commented-out lines of code should be removed.", DiagnosticSeverity.Warning)); + tuple(0, 13, 0, 16, "java:S1118", "sonarqube", "Add a private constructor to hide the implicit public one.", DiagnosticSeverity.Warning), + tuple(0, 0, 0, 0, "java:S1220", "sonarqube", "Move this file to a named package.", DiagnosticSeverity.Warning), + tuple(2, 5, 2, 31, "java:S125", "sonarqube", "This block of commented-out lines of code should be removed.", DiagnosticSeverity.Warning)); }); } } diff --git a/src/test/java/org/sonarsource/sonarlint/ls/mediumtests/LanguageServerMediumTests.java b/src/test/java/org/sonarsource/sonarlint/ls/mediumtests/LanguageServerMediumTests.java index d7046b524..4ae21f70d 100644 --- a/src/test/java/org/sonarsource/sonarlint/ls/mediumtests/LanguageServerMediumTests.java +++ b/src/test/java/org/sonarsource/sonarlint/ls/mediumtests/LanguageServerMediumTests.java @@ -145,8 +145,8 @@ void analyzeSimpleJsFileOnOpen() throws Exception { awaitUntilAsserted(() -> assertThat(client.getDiagnostics(uri)) .extracting(startLine(), startCharacter(), endLine(), endCharacter(), code(), Diagnostic::getSource, Diagnostic::getMessage, Diagnostic::getSeverity) .containsExactlyInAnyOrder( - tuple(1, 6, 1, 10, "javascript:S1481", "sonarlint", "Remove the declaration of the unused 'toto' variable.", DiagnosticSeverity.Warning), - tuple(2, 6, 2, 11, "javascript:S1481", "sonarlint", "Remove the declaration of the unused 'plouf' variable.", DiagnosticSeverity.Warning))); + tuple(1, 6, 1, 10, "javascript:S1481", "sonarqube", "Remove the declaration of the unused 'toto' variable.", DiagnosticSeverity.Warning), + tuple(2, 6, 2, 11, "javascript:S1481", "sonarqube", "Remove the declaration of the unused 'plouf' variable.", DiagnosticSeverity.Warning))); } @Test @@ -159,7 +159,7 @@ void analyzeSimpleTsFileOnOpen() throws Exception { awaitUntilAsserted(() -> assertThat(client.getDiagnostics(uri)) .extracting(startLine(), startCharacter(), endLine(), endCharacter(), code(), Diagnostic::getSource, Diagnostic::getMessage, Diagnostic::getSeverity) - .containsExactly(tuple(1, 13, 1, 18, "typescript:S1764", "sonarlint", "Correct one of the identical sub-expressions on both sides of operator \"&&\" [+1 location]", + .containsExactly(tuple(1, 13, 1, 18, "typescript:S1764", "sonarqube", "Correct one of the identical sub-expressions on both sides of operator \"&&\" [+1 location]", DiagnosticSeverity.Warning))); } @@ -182,8 +182,8 @@ func main() { awaitUntilAsserted(() -> assertThat(client.getDiagnostics(uri)) .extracting(startLine(), startCharacter(), endLine(), endCharacter(), code(), Diagnostic::getSource, Diagnostic::getMessage, Diagnostic::getSeverity) .containsExactly( - tuple(3, 15, 4, 2, GO_S108, "sonarlint", "Either remove or fill this block of code.", DiagnosticSeverity.Warning), - tuple(4, 11, 4, 21, GO_S1862, "sonarlint", "This condition duplicates the one on line 4. [+1 location]", DiagnosticSeverity.Warning))); + tuple(3, 15, 4, 2, GO_S108, "sonarqube", "Either remove or fill this block of code.", DiagnosticSeverity.Warning), + tuple(4, 11, 4, 21, GO_S1862, "sonarqube", "This condition duplicates the one on line 4. [+1 location]", DiagnosticSeverity.Warning))); } @Test @@ -211,9 +211,9 @@ void analyzeSimpleCloudFormationFileOnOpen() throws Exception { .extracting(startLine(), startCharacter(), endLine(), endCharacter(), code(), Diagnostic::getSource, Diagnostic::getMessage, Diagnostic::getSeverity) .containsExactly( tuple(7, 15, 7, 39, CLOUDFORMATION_S6273, - "sonarlint", "Rename tag key \"anycompany:cost-center\" to match the regular expression \"^([A-Z][A-Za-z]*:)*([A-Z][A-Za-z]*)$\".", + "sonarqube", "Rename tag key \"anycompany:cost-center\" to match the regular expression \"^([A-Z][A-Za-z]*:)*([A-Z][A-Za-z]*)$\".", DiagnosticSeverity.Warning), - tuple(9, 15, 9, 43, CLOUDFORMATION_S6273, "sonarlint", + tuple(9, 15, 9, 43, CLOUDFORMATION_S6273, "sonarqube", "Rename tag key \"anycompany:EnvironmentType\" to match the regular expression \"^([A-Z][A-Za-z]*:)*([A-Z][A-Za-z]*)$\".", DiagnosticSeverity.Warning))); } @@ -230,8 +230,8 @@ void analyzeSimpleDockerFileOnOpen() throws Exception { awaitUntilAsserted(() -> assertThat(client.getDiagnostics(uri)) .extracting(startLine(), startCharacter(), endLine(), endCharacter(), code(), Diagnostic::getSource, Diagnostic::getMessage, Diagnostic::getSeverity) .containsExactly( - tuple(0, 18, 0, 20, DOCKER_S6476, "sonarlint", "Replace `as` with upper case format `AS`.", DiagnosticSeverity.Warning), - tuple(0, 0, 0, 4, DOCKER_S6476, "sonarlint", "Replace `from` with upper case format `FROM`.", DiagnosticSeverity.Warning))); + tuple(0, 18, 0, 20, DOCKER_S6476, "sonarqube", "Replace `as` with upper case format `AS`.", DiagnosticSeverity.Warning), + tuple(0, 0, 0, 4, DOCKER_S6476, "sonarqube", "Replace `from` with upper case format `FROM`.", DiagnosticSeverity.Warning))); } @Test @@ -254,7 +254,7 @@ void analyzeSimpleTerraformFileOnOpen() throws Exception { awaitUntilAsserted(() -> assertThat(client.getDiagnostics(uri)) .extracting(startLine(), startCharacter(), endLine(), endCharacter(), code(), Diagnostic::getSource, Diagnostic::getMessage, Diagnostic::getSeverity) .containsExactly( - tuple(4, 4, 4, 28, TERRAFORM_S6273, "sonarlint", + tuple(4, 4, 4, 28, TERRAFORM_S6273, "sonarqube", "Rename tag key \"anycompany:cost-center\" to match the regular expression \"^([A-Z][A-Za-z]*:)*([A-Z][A-Za-z]*)$\".", DiagnosticSeverity.Warning))); } @@ -277,7 +277,7 @@ void analyzeSimpleBicepFileOnOpen() throws Exception { awaitUntilAsserted(() -> assertThat(client.getDiagnostics(uri)) .extracting(startLine(), startCharacter(), endLine(), endCharacter(), code(), Diagnostic::getSource, Diagnostic::getMessage, Diagnostic::getSeverity) .containsExactly( - tuple(3, 4, 3, 31, ARM_S4423, "sonarlint", + tuple(3, 4, 3, 31, ARM_S4423, "sonarqube", "Change this code to disable support of older TLS versions.", DiagnosticSeverity.Warning))); } @@ -308,7 +308,7 @@ void analyzeSimpleArmJsonFileOnOpen() throws Exception { awaitUntilAsserted(() -> assertThat(client.getDiagnostics(uri)) .extracting(startLine(), startCharacter(), endLine(), endCharacter(), code(), Diagnostic::getSource, Diagnostic::getMessage, Diagnostic::getSeverity) .containsExactly( - tuple(9, 8, 9, 37, ARM_S4423, "sonarlint", + tuple(9, 8, 9, 37, ARM_S4423, "sonarqube", "Change this code to disable support of older TLS versions.", DiagnosticSeverity.Warning))); } @@ -321,7 +321,7 @@ void analyzeSimplePythonFileOnOpen() throws Exception { awaitUntilAsserted(() -> assertThat(client.getDiagnostics(uri)) .extracting(startLine(), startCharacter(), endLine(), endCharacter(), code(), Diagnostic::getSource, Diagnostic::getMessage, Diagnostic::getSeverity) .containsExactly( - tuple(1, 2, 1, 7, "python:PrintStatementUsage", "sonarlint", "Replace print statement by built-in function.", DiagnosticSeverity.Warning))); + tuple(1, 2, 1, 7, "python:PrintStatementUsage", "sonarqube", "Replace print statement by built-in function.", DiagnosticSeverity.Warning))); } @Test @@ -352,8 +352,8 @@ void analyzeSimplePythonFileWithCustomRuleConfig() throws Exception { awaitUntilAsserted(() -> assertThat(client.getDiagnostics(uri)) .extracting(startLine(), startCharacter(), endLine(), endCharacter(), code(), Diagnostic::getSource, Diagnostic::getMessage, Diagnostic::getSeverity) .containsExactlyInAnyOrder( - tuple(1, 2, 1, 6, PYTHON_S1481, "sonarlint", "Remove the unused local variable \"toto\".", DiagnosticSeverity.Warning), - tuple(2, 2, 2, 7, PYTHON_S1481, "sonarlint", "Remove the unused local variable \"plouf\".", DiagnosticSeverity.Warning))); + tuple(1, 2, 1, 6, PYTHON_S1481, "sonarqube", "Remove the unused local variable \"toto\".", DiagnosticSeverity.Warning), + tuple(2, 2, 2, 7, PYTHON_S1481, "sonarqube", "Remove the unused local variable \"plouf\".", DiagnosticSeverity.Warning))); client.clear(); @@ -364,7 +364,7 @@ void analyzeSimplePythonFileWithCustomRuleConfig() throws Exception { awaitUntilAsserted(() -> assertThat(client.getDiagnostics(uri)) .extracting(startLine(), startCharacter(), endLine(), endCharacter(), code(), Diagnostic::getSource, Diagnostic::getMessage, Diagnostic::getSeverity) .containsExactlyInAnyOrder( - tuple(2, 14, 2, 69, PYTHON_S139, "sonarlint", "Move this trailing comment on the previous empty line.", DiagnosticSeverity.Warning) + tuple(2, 14, 2, 69, PYTHON_S139, "sonarqube", "Move this trailing comment on the previous empty line.", DiagnosticSeverity.Warning) // Expected issues on python:S1481 are suppressed by rule configuration )); } @@ -378,7 +378,7 @@ void analyzePythonFileWithDuplicatedStringOnOpen() throws Exception { awaitUntilAsserted(() -> assertThat(client.getDiagnostics(uri)) .extracting(startLine(), startCharacter(), endLine(), endCharacter(), code(), Diagnostic::getSource, Diagnostic::getMessage, Diagnostic::getSeverity) .containsExactly( - tuple(1, 8, 1, 15, "python:S1192", "sonarlint", "Define a constant instead of duplicating this literal '/toto' 3 times. [+2 locations]", DiagnosticSeverity.Warning))); + tuple(1, 8, 1, 15, "python:S1192", "sonarqube", "Define a constant instead of duplicating this literal '/toto' 3 times. [+2 locations]", DiagnosticSeverity.Warning))); var d = client.getDiagnostics(uri).get(0); var codeActionParams = new CodeActionParams(new TextDocumentIdentifier(uri), d.getRange(), new CodeActionContext(List.of(d))); @@ -398,9 +398,9 @@ void analyzeSimplePhpFileOnOpen() throws Exception { awaitUntilAsserted(() -> assertThat(client.getDiagnostics(uri)) .extracting(startLine(), startCharacter(), endLine(), endCharacter(), code(), Diagnostic::getSource, Diagnostic::getMessage, Diagnostic::getSeverity) .containsExactlyInAnyOrder( - tuple(0, 0, 0, 0, "php:S113", "sonarlint", "Add a new line at the end of this file.", DiagnosticSeverity.Warning), - tuple(2, 2, 2, 15, "php:S6600", "sonarlint", "Remove the parentheses from this \"echo\" call.", DiagnosticSeverity.Warning), - tuple(4, 0, 4, 2, "php:S1780", "sonarlint", "Remove this closing tag \"?>\".", DiagnosticSeverity.Warning))); + tuple(0, 0, 0, 0, "php:S113", "sonarqube", "Add a new line at the end of this file.", DiagnosticSeverity.Warning), + tuple(2, 2, 2, 15, "php:S6600", "sonarqube", "Remove the parentheses from this \"echo\" call.", DiagnosticSeverity.Warning), + tuple(4, 0, 4, 2, "php:S1780", "sonarqube", "Remove this closing tag \"?>\".", DiagnosticSeverity.Warning))); } @Test @@ -412,11 +412,11 @@ void analyzeSimpleHtmlFileOnOpen() throws Exception { awaitUntilAsserted(() -> assertThat(client.getDiagnostics(uri)) .extracting(startLine(), startCharacter(), endLine(), endCharacter(), code(), Diagnostic::getSource, Diagnostic::getMessage, Diagnostic::getSeverity) .containsExactlyInAnyOrder( - tuple(0, 0, 0, 6, "Web:DoctypePresenceCheck", "sonarlint", "Insert a declaration to before this tag.", + tuple(0, 0, 0, 6, "Web:DoctypePresenceCheck", "sonarqube", "Insert a declaration to before this tag.", DiagnosticSeverity.Warning), - tuple(0, 0, 0, 6, "Web:S5254", "sonarlint", "Add \"lang\" and/or \"xml:lang\" attributes to this \"\" element", + tuple(0, 0, 0, 6, "Web:S5254", "sonarqube", "Add \"lang\" and/or \"xml:lang\" attributes to this \"\" element", DiagnosticSeverity.Warning), - tuple(0, 0, 0, 26, "Web:PageWithoutTitleCheck", "sonarlint", "Add a tag to this page.", DiagnosticSeverity.Warning))); + tuple(0, 0, 0, 26, "Web:PageWithoutTitleCheck", "sonarqube", "Add a <title> tag to this page.", DiagnosticSeverity.Warning))); } @Test @@ -428,11 +428,11 @@ void analyzeSimpleJspFileOnOpen() throws Exception { awaitUntilAsserted(() -> assertThat(client.getDiagnostics(uri)) .extracting(startLine(), startCharacter(), endLine(), endCharacter(), code(), Diagnostic::getSource, Diagnostic::getMessage, Diagnostic::getSeverity) .containsExactlyInAnyOrder( - tuple(0, 0, 0, 6, "Web:DoctypePresenceCheck", "sonarlint", "Insert a <!DOCTYPE> declaration to before this <html> tag.", + tuple(0, 0, 0, 6, "Web:DoctypePresenceCheck", "sonarqube", "Insert a <!DOCTYPE> declaration to before this <html> tag.", DiagnosticSeverity.Warning), - tuple(0, 0, 0, 6, "Web:S5254", "sonarlint", "Add \"lang\" and/or \"xml:lang\" attributes to this \"<html>\" element", + tuple(0, 0, 0, 6, "Web:S5254", "sonarqube", "Add \"lang\" and/or \"xml:lang\" attributes to this \"<html>\" element", DiagnosticSeverity.Warning), - tuple(0, 0, 0, 26, "Web:PageWithoutTitleCheck", "sonarlint", "Add a <title> tag to this page.", DiagnosticSeverity.Warning))); + tuple(0, 0, 0, 26, "Web:PageWithoutTitleCheck", "sonarqube", "Add a <title> tag to this page.", DiagnosticSeverity.Warning))); } @Test @@ -484,7 +484,7 @@ void analyzeSimplePythonFileOnChange() throws Exception { awaitUntilAsserted(() -> assertThat(client.getDiagnostics(uri)) .extracting(startLine(), startCharacter(), endLine(), endCharacter(), code(), Diagnostic::getSource, Diagnostic::getMessage, Diagnostic::getSeverity) - .containsExactly(tuple(1, 2, 1, 6, PYTHON_S1481, "sonarlint", "Remove the unused local variable \"toto\".", DiagnosticSeverity.Warning))); + .containsExactly(tuple(1, 2, 1, 6, PYTHON_S1481, "sonarqube", "Remove the unused local variable \"toto\".", DiagnosticSeverity.Warning))); } @Test @@ -496,11 +496,11 @@ void cleanUpDiagnosticsOnFileClose() throws IOException { awaitUntilAsserted(() -> assertThat(client.getDiagnostics(uri)) .extracting(startLine(), startCharacter(), endLine(), endCharacter(), code(), Diagnostic::getSource, Diagnostic::getMessage, Diagnostic::getSeverity) .containsExactlyInAnyOrder( - tuple(0, 0, 0, 6, "Web:DoctypePresenceCheck", "sonarlint", "Insert a <!DOCTYPE> declaration to before this <html> tag.", + tuple(0, 0, 0, 6, "Web:DoctypePresenceCheck", "sonarqube", "Insert a <!DOCTYPE> declaration to before this <html> tag.", DiagnosticSeverity.Warning), - tuple(0, 0, 0, 6, "Web:S5254", "sonarlint", "Add \"lang\" and/or \"xml:lang\" attributes to this \"<html>\" element", + tuple(0, 0, 0, 6, "Web:S5254", "sonarqube", "Add \"lang\" and/or \"xml:lang\" attributes to this \"<html>\" element", DiagnosticSeverity.Warning), - tuple(0, 0, 0, 26, "Web:PageWithoutTitleCheck", "sonarlint", "Add a <title> tag to this page.", DiagnosticSeverity.Warning))); + tuple(0, 0, 0, 26, "Web:PageWithoutTitleCheck", "sonarqube", "Add a <title> tag to this page.", DiagnosticSeverity.Warning))); didClose(uri); @@ -519,7 +519,7 @@ void analyzeSimpleXmlFileOnOpen() throws Exception { awaitUntilAsserted(() -> assertThat(client.getDiagnostics(uri)) .extracting(startLine(), startCharacter(), endLine(), endCharacter(), code(), Diagnostic::getSource, Diagnostic::getMessage, Diagnostic::getSeverity) .containsExactly( - tuple(2, 2, 2, 27, "xml:S1135", "sonarlint", "Complete the task associated to this \"TODO\" comment.", DiagnosticSeverity.Warning))); + tuple(2, 2, 2, 27, "xml:S1135", "sonarqube", "Complete the task associated to this \"TODO\" comment.", DiagnosticSeverity.Warning))); } @Test @@ -531,7 +531,7 @@ void analyzeSimpleCssFileOnOpen() throws Exception { awaitUntilAsserted(() -> assertThat(client.getDiagnostics(uri)) .extracting(startLine(), startCharacter(), endLine(), endCharacter(), code(), Diagnostic::getSource, Diagnostic::getMessage, Diagnostic::getSeverity) .containsExactly( - tuple(0, 0, 0, 4, "css:S4658", "sonarlint", "Unexpected empty block", DiagnosticSeverity.Warning))); + tuple(0, 0, 0, 4, "css:S4658", "sonarqube", "Unexpected empty block", DiagnosticSeverity.Warning))); } @Test @@ -560,8 +560,8 @@ void delayAnalysisOnChange() throws Exception { awaitUntilAsserted(() -> assertThat(client.getDiagnostics(uri)) .extracting(startLine(), startCharacter(), endLine(), endCharacter(), code(), Diagnostic::getSource, Diagnostic::getMessage, Diagnostic::getSeverity) .containsExactly( - tuple(1, 2, 1, 6, PYTHON_S1481, "sonarlint", "Remove the unused local variable \"toto\".", DiagnosticSeverity.Warning), - tuple(2, 2, 2, 7, PYTHON_S1481, "sonarlint", "Remove the unused local variable \"plouf\".", DiagnosticSeverity.Warning))); + tuple(1, 2, 1, 6, PYTHON_S1481, "sonarqube", "Remove the unused local variable \"toto\".", DiagnosticSeverity.Warning), + tuple(2, 2, 2, 7, PYTHON_S1481, "sonarqube", "Remove the unused local variable \"plouf\".", DiagnosticSeverity.Warning))); } @Test @@ -729,16 +729,16 @@ function sum(a, b) { var list = lsProxy.getTextDocumentService().codeAction(codeActionParams).get(); assertThat(list).hasSize(3); var codeAction = list.get(0).getRight(); - assertThat(codeAction.getTitle()).isEqualTo("SonarLint: Show issue details for 'javascript:S930'"); + assertThat(codeAction.getTitle()).isEqualTo("SonarQube: Show issue details for 'javascript:S930'"); var openRuleDesc = codeAction.getCommand(); assertThat(openRuleDesc.getCommand()).isEqualTo("SonarLint.ShowIssueDetailsCodeAction"); assertThat(openRuleDesc.getArguments()).hasSize(2); assertThat(((JsonPrimitive) openRuleDesc.getArguments().get(0)).getAsString()).isEqualTo(issueId); assertThat(((JsonPrimitive) openRuleDesc.getArguments().get(1)).getAsString()).isEqualTo(uri); var showAllLocationsCodeAction = list.get(1).getRight(); - assertThat(showAllLocationsCodeAction.getTitle()).isEqualTo("SonarLint: Show all locations for issue 'javascript:S930'"); + assertThat(showAllLocationsCodeAction.getTitle()).isEqualTo("SonarQube: Show all locations for issue 'javascript:S930'"); var disableRuleCodeAction = list.get(2).getRight(); - assertThat(disableRuleCodeAction.getTitle()).isEqualTo("SonarLint: Deactivate rule 'javascript:S930'"); + assertThat(disableRuleCodeAction.getTitle()).isEqualTo("SonarQube: Deactivate rule 'javascript:S930'"); var disableRule = disableRuleCodeAction.getCommand(); assertThat(disableRule.getCommand()).isEqualTo("SonarLint.DeactivateRule"); assertThat(disableRule.getArguments()).hasSize(1); @@ -894,7 +894,7 @@ void preservePreviousDiagnosticsWhenFileHasParsingErrors() throws Exception { awaitUntilAsserted(() -> assertThat(client.getDiagnostics(uri)) .extracting(startLine(), startCharacter(), endLine(), endCharacter(), code(), Diagnostic::getSource, Diagnostic::getMessage, Diagnostic::getSeverity) .containsExactly( - tuple(1, 2, 1, 7, "python:PrintStatementUsage", "sonarlint", "Replace print statement by built-in function.", DiagnosticSeverity.Warning))); + tuple(1, 2, 1, 7, "python:PrintStatementUsage", "sonarqube", "Replace print statement by built-in function.", DiagnosticSeverity.Warning))); client.logs.clear(); @@ -909,7 +909,7 @@ void preservePreviousDiagnosticsWhenFileHasParsingErrors() throws Exception { assertThat(client.getDiagnostics(uri)) .extracting(startLine(), startCharacter(), endLine(), endCharacter(), code(), Diagnostic::getSource, Diagnostic::getMessage, Diagnostic::getSeverity) .containsExactly( - tuple(1, 2, 1, 7, "python:PrintStatementUsage", "sonarlint", "Replace print statement by built-in function.", DiagnosticSeverity.Warning)); + tuple(1, 2, 1, 7, "python:PrintStatementUsage", "sonarqube", "Replace print statement by built-in function.", DiagnosticSeverity.Warning)); } @Test @@ -1128,7 +1128,7 @@ void analyseOpenFileIgnoringExcludes() { .extracting(startLine(), startCharacter(), endLine(), endCharacter(), code(), Diagnostic::getSource, Diagnostic::getMessage, Diagnostic::getSeverity) .containsExactlyInAnyOrder( - tuple(1, 2, 1, 6, PYTHON_S1481, "sonarlint", "Remove the unused local variable \"toto\".", DiagnosticSeverity.Warning))); + tuple(1, 2, 1, 6, PYTHON_S1481, "sonarqube", "Remove the unused local variable \"toto\".", DiagnosticSeverity.Warning))); } @Test diff --git a/src/test/java/org/sonarsource/sonarlint/ls/mediumtests/LanguageServerWithFoldersMediumTests.java b/src/test/java/org/sonarsource/sonarlint/ls/mediumtests/LanguageServerWithFoldersMediumTests.java index 8808fe7bf..594d406d6 100644 --- a/src/test/java/org/sonarsource/sonarlint/ls/mediumtests/LanguageServerWithFoldersMediumTests.java +++ b/src/test/java/org/sonarsource/sonarlint/ls/mediumtests/LanguageServerWithFoldersMediumTests.java @@ -124,8 +124,8 @@ void analysisShouldUseFolderSettings() throws Exception { awaitUntilAsserted(() -> assertThat(client.getDiagnostics(uriInFolder)) .extracting(startLine(), startCharacter(), endLine(), endCharacter(), code(), Diagnostic::getSource, Diagnostic::getMessage, Diagnostic::getSeverity) .containsExactly( - tuple(1, 2, 1, 6, PYTHON_S1481, "sonarlint", "Remove the unused local variable \"toto\".", DiagnosticSeverity.Warning), - tuple(2, 2, 2, 7, PYTHON_S1481, "sonarlint", "Remove the unused local variable \"plouf\".", DiagnosticSeverity.Warning))); + tuple(1, 2, 1, 6, PYTHON_S1481, "sonarqube", "Remove the unused local variable \"toto\".", DiagnosticSeverity.Warning), + tuple(2, 2, 2, 7, PYTHON_S1481, "sonarqube", "Remove the unused local variable \"plouf\".", DiagnosticSeverity.Warning))); client.logs.clear(); diff --git a/src/test/java/org/sonarsource/sonarlint/ls/mediumtests/NotebookMediumTests.java b/src/test/java/org/sonarsource/sonarlint/ls/mediumtests/NotebookMediumTests.java index 7ff671fa1..a3aa24a9a 100644 --- a/src/test/java/org/sonarsource/sonarlint/ls/mediumtests/NotebookMediumTests.java +++ b/src/test/java/org/sonarsource/sonarlint/ls/mediumtests/NotebookMediumTests.java @@ -79,7 +79,7 @@ void analyzeNotebookOnOpen() throws Exception { awaitUntilAsserted(() -> assertThat(client.getDiagnostics(uri + "#2")) .extracting(startLine(), startCharacter(), endLine(), endCharacter(), code(), Diagnostic::getSource, Diagnostic::getMessage, Diagnostic::getSeverity) .containsExactly( - tuple(1, 2, 1, 7, "ipython:PrintStatementUsage", "sonarlint", "Replace print statement by built-in function.", DiagnosticSeverity.Warning))); + tuple(1, 2, 1, 7, "ipython:PrintStatementUsage", "sonarqube", "Replace print statement by built-in function.", DiagnosticSeverity.Warning))); assertThat(client.getDiagnostics(uri + "#1")).isEmpty(); assertThat(client.getDiagnostics(uri)).isEmpty(); @@ -125,6 +125,6 @@ void analyseOpenNotebookIgnoringExcludes() { .extracting(startLine(), startCharacter(), endLine(), endCharacter(), code(), Diagnostic::getSource, Diagnostic::getMessage, Diagnostic::getSeverity) .containsExactlyInAnyOrder( - tuple(1, 2, 1, 7, "ipython:PrintStatementUsage", "sonarlint", "Replace print statement by built-in function.", DiagnosticSeverity.Warning))); + tuple(1, 2, 1, 7, "ipython:PrintStatementUsage", "sonarqube", "Replace print statement by built-in function.", DiagnosticSeverity.Warning))); } }