Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SLVSCODE-834 store SonarCloud tokens properly #613

Merged

Conversation

sophio-japharidze-sonarsource
Copy link
Contributor

@sophio-japharidze-sonarsource sophio-japharidze-sonarsource commented Aug 22, 2024

SLVSCODE-834

It is amazing how many hidden problems this was causing 🥲

Copy link
Member

@jblievremont jblievremont left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM on the functional side (and good catch!), I suggested an additional change that could avoid similar silent bugs in the future.

@@ -91,7 +91,7 @@ export function confirmConnectionDetailsAndSave(context: vscode.ExtensionContext
if (isSonarCloud) {
const sonarCloudToken = token || await ConnectionSettingsService.instance.getServerToken(serverUrlOrOrganizationKey);
const connection = {
sonarCloudToken,
token: sonarCloudToken,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest the following change (and similar below for the SQ connection):

const connection: SonarCloudConnection = {
  token: sonarCloudToken,
  connectionId: serverUrlOrOrganizationKey,
  disableNotifications: false,
  organizationKey: serverUrlOrOrganizationKey
};

With this explicit type declaration, the TS compiler correctly flags the sonarCloudToken property as invalid for the SonarCloudConnection type, instead of silently accepting it with the as cast.

Copy link
Member

@jblievremont jblievremont left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍🏻 !

@sophio-japharidze-sonarsource sophio-japharidze-sonarsource merged commit c5a3597 into master Aug 22, 2024
11 checks passed
@sophio-japharidze-sonarsource sophio-japharidze-sonarsource deleted the SLVSCODE-834_store_sc_token_properly branch August 22, 2024 13:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants