From a2fa6ed5f1e7cee4f8218a0c4e96fbb8f9f910bd Mon Sep 17 00:00:00 2001 From: Sophio Japharidze Date: Tue, 2 Jul 2024 11:28:05 +0200 Subject: [PATCH] SLVSCODE-788 properly read data coming from the server --- CHANGELOG.md | 2 +- src/connected/connectionsetup.ts | 17 +++++++++++------ 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 46864485f..f696a769c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,7 @@ ## 4.7 * Allow focusing on New Code for standalone projects. [Learn more](https://docs.sonarsource.com/sonarlint/vs-code/concepts/new-code/) -* Automatic toke exchange when setting up SonarCloud connection +* Automatic token exchange when setting up SonarCloud connection * Update text and secrets analyzer 2.10 -> [2.11](https://github.com/SonarSource/sonar-text-enterprise/releases/tag/2.11.0.2807) -> [2.12](https://github.com/SonarSource/sonar-text-enterprise/releases/tag/2.12.0.2889) -> [2.12.1](https://github.com/SonarSource/sonar-text-enterprise/releases/tag/2.12.1.2905), bugfixes, FP fixes * Update CFamily analyzer 6.55 -> [6.56](https://sonarsource.atlassian.net/issues/?jql=fixversion%20%3D%206.56%20ORDER%20BY%20created%20ASC), Linux ARM support, c++23 deducing this, rules hardening * Update C# analyzer 9.25 -> [9.25.1](https://github.com/SonarSource/sonar-dotnet/releases/tag/9.25.1.91650) -> [9.26](https://github.com/SonarSource/sonar-dotnet/releases/tag/9.26.0.92422) -> [9.27](https://github.com/SonarSource/sonar-dotnet/releases/tag/9.27.0.93347), new rules, FP fixes and improvements diff --git a/src/connected/connectionsetup.ts b/src/connected/connectionsetup.ts index 9a49af6b6..ec856dc01 100644 --- a/src/connected/connectionsetup.ts +++ b/src/connected/connectionsetup.ts @@ -48,7 +48,7 @@ const SONARCLOUD_DESCRIPTION = export function assistCreatingConnection(context: vscode.ExtensionContext) { return async assistCreatingConnectionParams => { - return { newConnectionId: await confirmConnectionDetailsAndSave(context)(assistCreatingConnectionParams.isSonarCloud, assistCreatingConnectionParams.serverUrlOrOrganizationKey, assistCreatingConnectionParams.token) } + return { newConnectionId: await confirmConnectionDetailsAndSave(context)(assistCreatingConnectionParams.isSonarCloud, assistCreatingConnectionParams.serverUrlOrOrganisationKey, assistCreatingConnectionParams.token) } }; } @@ -58,16 +58,21 @@ interface ConnectionConfirmationResponse { } async function confirmConnection(isSonarCloud : boolean, serverUrlOrOrganizationKey: string, token: string) : Promise { - const manualConnectionMessage = `Connecting SonarLint to ${isSonarCloud ? 'SonarCloud' : 'SonarQube'} will enable issues to be opened directly in your IDE. It will also allow you to apply the same Clean Code standards as your team, analyze more languages, detect more issues, receive notifications about the quality gate status, and more. - \nEnsure that the requesting ${isSonarCloud ? 'organization' : 'server URL'} '${serverUrlOrOrganizationKey}' matches your ${isSonarCloud ? 'SonarCloud' : 'SonarQube'} instance. Letting SonarLint connect to an untrusted ${isSonarCloud ? 'SonarCloud' : 'SonarQube'} server is potentially dangerous. If you don't trust this server, we recommend canceling this action and manually setting up Connected Mode.`; + const connectionType = isSonarCloud ? 'SonarCloud organization' : 'SonarQube server'; + let manualConnectionMessage = `Connecting SonarLint to ${isSonarCloud ? 'SonarCloud' : 'SonarQube'} will enable issues to be opened directly in your IDE. It will also allow you to apply the same Clean Code standards as your team, analyze more languages, detect more issues, receive notifications about the quality gate status, and more. + \nEnsure that the requesting ${isSonarCloud ? 'organization' : 'server URL'} '${serverUrlOrOrganizationKey}' matches your ${connectionType}.`; + + if (!isSonarCloud) { + manualConnectionMessage += ` Letting SonarLint connect to an untrusted SonarQube server is potentially dangerous. If you don't trust this server, we recommend canceling this action and manually setting up Connected Mode.` + } const automaticConnectionMessage = `${manualConnectionMessage} - \nA token will be automatically generated to allow access to your ${isSonarCloud ? 'SonarCloud' : 'SonarQube'} instance.` + \nA token will be automatically generated to allow access to your ${connectionType}.` - const yesOption = `Connect to this ${isSonarCloud ? 'SonarCloud organization' : 'SonarQube server'}`; + const yesOption = `Connect to this ${connectionType}`; const learnMoreOption = 'What is Connected Mode?' const result = await vscode.window.showWarningMessage( - `Do you trust this ${isSonarCloud ? 'SonarCloud organization' : 'SonarQube server'}?`, + `Do you trust this ${connectionType}?`, { modal: true, detail: token ? automaticConnectionMessage : manualConnectionMessage }, yesOption, learnMoreOption