Skip to content

Commit 7e8ce35

Browse files
Remove the requiresAuthentication parameter
It is true by default and no place in the codebase sets it to false. We can simplify the code by removing this case we aren't using. If we want this behaviour in the future we can always implement it again, but I think it's likely to be unnecessary and if you don't want authenticated requests then you likely won't be initializing a Credentials object.
1 parent 0c483d1 commit 7e8ce35

2 files changed

Lines changed: 4 additions & 11 deletions

File tree

extensions/ql-vscode/src/authentication.ts

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -90,24 +90,17 @@ export class Credentials {
9090
/**
9191
* Creates or returns an instance of Octokit.
9292
*
93-
* @param requireAuthentication Whether the Octokit instance needs to be authenticated as user.
9493
* @returns An instance of Octokit.
9594
*/
96-
async getOctokit(requireAuthentication = true): Promise<Octokit.Octokit> {
95+
async getOctokit(): Promise<Octokit.Octokit> {
9796
if (this.octokit) {
9897
return this.octokit;
9998
}
10099

101-
this.octokit = await this.createOctokit(requireAuthentication);
100+
this.octokit = await this.createOctokit(true);
102101

103102
if (!this.octokit) {
104-
if (requireAuthentication) {
105-
throw new Error("Did not initialize Octokit.");
106-
}
107-
108-
// We don't want to set this in this.octokit because that would prevent
109-
// authenticating when requireCredentials is true.
110-
return new Octokit.Octokit({ retry });
103+
throw new Error("Did not initialize Octokit.");
111104
}
112105
return this.octokit;
113106
}

extensions/ql-vscode/src/databaseFetcher.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ export async function promptImportGithubDatabase(
106106
}
107107

108108
const octokit = credentials
109-
? await credentials.getOctokit(true)
109+
? await credentials.getOctokit()
110110
: new Octokit.Octokit({ retry });
111111

112112
const result = await convertGithubNwoToDatabaseUrl(nwo, octokit, progress);

0 commit comments

Comments
 (0)