Skip to content

Commit 8f34f6a

Browse files
Remove the createIfNone parameter from createOctokit
At this point we are only ever passing true, so we may as well remove the parameter and simplify the code.
1 parent 8c05b3a commit 8f34f6a

1 file changed

Lines changed: 7 additions & 19 deletions

File tree

extensions/ql-vscode/src/authentication.ts

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -51,23 +51,17 @@ export class Credentials {
5151
return c;
5252
}
5353

54-
private async createOctokit(
55-
createIfNone: boolean,
56-
): Promise<Octokit.Octokit | undefined> {
54+
private async createOctokit(): Promise<Octokit.Octokit> {
5755
const session = await vscode.authentication.getSession(
5856
GITHUB_AUTH_PROVIDER_ID,
5957
SCOPES,
60-
{ createIfNone },
58+
{ createIfNone: true },
6159
);
6260

63-
if (session) {
64-
return new Octokit.Octokit({
65-
auth: session.accessToken,
66-
retry,
67-
});
68-
} else {
69-
return undefined;
70-
}
61+
return new Octokit.Octokit({
62+
auth: session.accessToken,
63+
retry,
64+
});
7165
}
7266

7367
registerListeners(context: vscode.ExtensionContext): void {
@@ -87,14 +81,8 @@ export class Credentials {
8781
* @returns An instance of Octokit.
8882
*/
8983
async getOctokit(): Promise<Octokit.Octokit> {
90-
if (this.octokit) {
91-
return this.octokit;
92-
}
93-
94-
this.octokit = await this.createOctokit(true);
95-
9684
if (!this.octokit) {
97-
throw new Error("Did not initialize Octokit.");
85+
this.octokit = await this.createOctokit();
9886
}
9987
return this.octokit;
10088
}

0 commit comments

Comments
 (0)