Skip to content

Commit

Permalink
SLVSCODE-788 properly read data coming from the server
Browse files Browse the repository at this point in the history
  • Loading branch information
sophio-japharidze-sonarsource committed Jul 2, 2024
1 parent 52f6d72 commit a2fa6ed
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
17 changes: 11 additions & 6 deletions src/connected/connectionsetup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) }
};
}

Expand All @@ -58,16 +58,21 @@ interface ConnectionConfirmationResponse {
}

async function confirmConnection(isSonarCloud : boolean, serverUrlOrOrganizationKey: string, token: string) : Promise<ConnectionConfirmationResponse> {
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
Expand Down

0 comments on commit a2fa6ed

Please sign in to comment.