Skip to content

Commit 4e5a3c5

Browse files
committed
Fix Unhandled arguments bug
When we added an extra optional param `isTutorialDatabase` to `openDatabase` [1] , the tests all passed but there is at least one call [2] where this triggers an `Unhandled arguments` error. This is because the method call doesn't know which optional param we're passing. Let's revert back to the original method signature where we had just one optional parameter (the database name) and set it to a special "CodeQL Tutorial Database" value. We can then use this to understand that the extension is running in the codespace and we want to skip creating a skeleton pack for it since it's the tutorial database. [1]: https://github.com/github/vscode-codeql/blob/5e51bb57f5f76b57768fb6a3543f153f5752c23c/extensions/ql-vscode/src/local-databases.ts#L610 [2]: https://github.com/github/vscode-codeql/blob/5e51bb57f5f76b57768fb6a3543f153f5752c23c/extensions/ql-vscode/src/databaseFetcher.ts#L257-L262
1 parent 396fdb8 commit 4e5a3c5

3 files changed

Lines changed: 1 addition & 7 deletions

File tree

extensions/ql-vscode/src/local-databases-ui.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -379,14 +379,12 @@ export class DatabaseUI extends DisposableObject {
379379
);
380380

381381
let databaseItem = this.databaseManager.findDatabaseItem(uri);
382-
const isTutorialDatabase = true;
383382
if (databaseItem === undefined) {
384383
databaseItem = await this.databaseManager.openDatabase(
385384
progress,
386385
token,
387386
uri,
388387
"CodeQL Tutorial Database",
389-
isTutorialDatabase,
390388
);
391389
}
392390
await this.databaseManager.setCurrentDatabaseItem(databaseItem);

extensions/ql-vscode/src/local-databases.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -607,7 +607,6 @@ export class DatabaseManager extends DisposableObject {
607607
token: vscode.CancellationToken,
608608
uri: vscode.Uri,
609609
displayName?: string,
610-
isTutorialDatabase?: boolean,
611610
): Promise<DatabaseItem> {
612611
const contents = await DatabaseResolver.resolveDatabaseContents(uri);
613612
// Ignore the source archive for QLTest databases by default.
@@ -631,7 +630,7 @@ export class DatabaseManager extends DisposableObject {
631630
await this.addDatabaseItem(progress, token, databaseItem);
632631
await this.addDatabaseSourceArchiveFolder(databaseItem);
633632

634-
if (isCodespacesTemplate() && !isTutorialDatabase) {
633+
if (isCodespacesTemplate() && displayName !== "CodeQL Tutorial Database") {
635634
await this.createSkeletonPacks(databaseItem);
636635
}
637636

extensions/ql-vscode/test/vscode-tests/minimal-workspace/local-databases.test.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -715,14 +715,11 @@ describe("local databases", () => {
715715
it("should not offer to create a skeleton QL pack", async () => {
716716
jest.spyOn(Setting.prototype, "getValue").mockReturnValue(true);
717717

718-
const isTutorialDatabase = true;
719-
720718
await databaseManager.openDatabase(
721719
{} as ProgressCallback,
722720
{} as CancellationToken,
723721
mockDbItem.databaseUri,
724722
"CodeQL Tutorial Database",
725-
isTutorialDatabase,
726723
);
727724

728725
expect(createSkeletonPacksSpy).toBeCalledTimes(0);

0 commit comments

Comments
 (0)