Skip to content

Commit 0c483d1

Browse files
Remove places where we are checking if credentials are undefined
This cannot happen already, even before the other changes in this PR. The Credentials.initialize method can never return undefined, so these checks would never return true. The real place that checks that we are authenticated is in the vscode.authentication.getSession method, and it will reject the promise if the user declines to authenticate or anything else means we can't get an authenticated session. I feel justified in removing the tests for these cases because the code was never actually called in production, and we are covered by the vscode authentication library rejecting the promise. Any exception thrown from Credentials.initialize would behave the same as the one I'm deleting.
1 parent dbdb4ba commit 0c483d1

5 files changed

Lines changed: 452 additions & 552 deletions

File tree

extensions/ql-vscode/src/remote-queries/remote-queries-monitor.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,6 @@ export class RemoteQueriesMonitor {
2727
): Promise<RemoteQueryWorkflowResult> {
2828
const credentials = await Credentials.initialize(this.extensionContext);
2929

30-
if (!credentials) {
31-
throw Error("Error authenticating with GitHub");
32-
}
33-
3430
let attemptCount = 0;
3531

3632
while (attemptCount <= RemoteQueriesMonitor.maxAttemptCount) {

extensions/ql-vscode/src/remote-queries/variant-analysis-manager.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -480,9 +480,6 @@ export class VariantAnalysisManager
480480
await this.onRepoStateUpdated(variantAnalysis.id, repoState);
481481

482482
const credentials = await Credentials.initialize(this.ctx);
483-
if (!credentials) {
484-
throw Error("Error authenticating with GitHub");
485-
}
486483

487484
if (cancellationToken && cancellationToken.isCancellationRequested) {
488485
repoState.downloadStatus =
@@ -581,9 +578,6 @@ export class VariantAnalysisManager
581578
}
582579

583580
const credentials = await Credentials.initialize(this.ctx);
584-
if (!credentials) {
585-
throw Error("Error authenticating with GitHub");
586-
}
587581

588582
void showAndLogInformationMessage(
589583
"Cancelling variant analysis. This may take a while.",

extensions/ql-vscode/src/remote-queries/variant-analysis-monitor.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,6 @@ export class VariantAnalysisMonitor extends DisposableObject {
4545
cancellationToken: CancellationToken,
4646
): Promise<void> {
4747
const credentials = await Credentials.initialize(this.extensionContext);
48-
if (!credentials) {
49-
throw Error("Error authenticating with GitHub");
50-
}
5148

5249
let attemptCount = 0;
5350
const scannedReposDownloaded: number[] = [];

0 commit comments

Comments
 (0)