-
Notifications
You must be signed in to change notification settings - Fork 191
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
Integrate codeql database unbundle #971
Integrate codeql database unbundle #971
Conversation
Co-authored by: Marc Jaramillo [email protected] Co-authored by: Musab Guma'a [email protected]
ef12f4f
to
b22a869
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is looking really good. There are still a few things left. Mostly, we can simplify things now that we are can handle both the old and new behaviour.
if (this.queryServer && await this.queryServer.cliServer.cliConstraints.supportsDatabaseUnbundle()) { | ||
return await promptImportInternetDatabase( | ||
this.databaseManager, | ||
this.storagePath, | ||
progress, | ||
token, | ||
this.queryServer.cliServer | ||
); | ||
} else { | ||
return await promptImportInternetDatabase( | ||
this.databaseManager, | ||
this.storagePath, | ||
progress, | ||
token | ||
); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This check is redundant. It is already taking place in readAndUnzip
.
if (this.queryServer && await this.queryServer.cliServer.cliConstraints.supportsDatabaseUnbundle()) { | |
return await promptImportInternetDatabase( | |
this.databaseManager, | |
this.storagePath, | |
progress, | |
token, | |
this.queryServer.cliServer | |
); | |
} else { | |
return await promptImportInternetDatabase( | |
this.databaseManager, | |
this.storagePath, | |
progress, | |
token | |
); | |
} | |
return await promptImportInternetDatabase( | |
this.databaseManager, | |
this.storagePath, | |
progress, | |
token, | |
this.queryServer.cliServer | |
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Making this change gives me an error, specifically that queryServer could be undefined.
handleChooseDatabaseInternet = async (
progress: ProgressCallback,
token: CancellationToken
): Promise<DatabaseItem | undefined> => {
return await promptImportInternetDatabase(
this.databaseManager,
this.storagePath,
progress,
token,
this.queryServer.cliServer
);
};
Doing it this way gives no error:
handleChooseDatabaseInternet = async (
progress: ProgressCallback,
token: CancellationToken
): Promise<DatabaseItem | undefined> => {
return await promptImportInternetDatabase(
this.databaseManager,
this.storagePath,
progress,
token,
this.queryServer?.cliServer
);
};
if (this.queryServer && await this.queryServer.cliServer.cliConstraints.supportsDatabaseUnbundle()) { | ||
return await promptImportLgtmDatabase( | ||
this.databaseManager, | ||
this.storagePath, | ||
progress, | ||
token, | ||
this.queryServer.cliServer | ||
); | ||
} else { | ||
return await promptImportLgtmDatabase( | ||
this.databaseManager, | ||
this.storagePath, | ||
progress, | ||
token | ||
); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here
if (this.queryServer && await this.queryServer.cliServer.cliConstraints.supportsDatabaseUnbundle()) { | |
return await promptImportLgtmDatabase( | |
this.databaseManager, | |
this.storagePath, | |
progress, | |
token, | |
this.queryServer.cliServer | |
); | |
} else { | |
return await promptImportLgtmDatabase( | |
this.databaseManager, | |
this.storagePath, | |
progress, | |
token | |
); | |
} | |
if (this.queryServer && await this.queryServer.cliServer.cliConstraints.supportsDatabaseUnbundle()) { | |
return await promptImportLgtmDatabase( | |
this.databaseManager, | |
this.storagePath, | |
progress, | |
token, | |
this.queryServer.cliServer | |
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When I remove the else block completely, I get a warning that not all code paths return a value.
handleChooseDatabaseLgtm = async (
progress: ProgressCallback,
token: CancellationToken
): Promise<DatabaseItem | undefined> => {
if (this.queryServer && await this.queryServer.cliServer.cliConstraints.supportsDatabaseUnbundle()) {
return await promptImportLgtmDatabase(
this.databaseManager,
this.storagePath,
progress,
token,
this.queryServer.cliServer
);
}
};
Is that what you'd like me to do? Or should it look like this:
handleChooseDatabaseLgtm = async (
progress: ProgressCallback,
token: CancellationToken
): Promise<DatabaseItem | undefined> => {
if (this.queryServer && await this.queryServer.cliServer.cliConstraints.supportsDatabaseUnbundle()) {
return await promptImportLgtmDatabase(
this.databaseManager,
this.storagePath,
progress,
token,
this.queryServer.cliServer
);
}
return await promptImportLgtmDatabase(
this.databaseManager,
this.storagePath,
progress,
token
);
};
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops...should be the same as above. You don't need the if statement at all.
handleChooseDatabaseLgtm = async (
progress: ProgressCallback,
token: CancellationToken
): Promise<DatabaseItem | undefined> => {
return await promptImportLgtmDatabase(
this.databaseManager,
this.storagePath,
progress,
token,
this?.queryServer.cliServer
);
};
This works because you are testing for the cliServer later when you actually try to call unbundle.
if (!this.queryServer) { | ||
throw new Error('Query server not started'); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now, this check is no longer needed. You can just fall back to the old behaviour if hte query server doesn't exist.
if (!this.queryServer) { | |
throw new Error('Query server not started'); | |
} |
@@ -713,7 +740,8 @@ export class DatabaseUI extends DisposableObject { | |||
this.databaseManager, | |||
this.storagePath, | |||
progress, | |||
token | |||
token, | |||
this.queryServer.cliServer |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this.queryServer.cliServer | |
this?.queryServer.cliServer |
if (!this.queryServer) { | ||
throw new Error('Query server not started'); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See comment below, this is no longer needed
Co-authored by: Marc Jaramillo [email protected] Co-authored by: Musab Guma'a [email protected]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. Let's ship it.
Fixes #1660
Checklist
@github/docs-content-codeql
has been cc'd in all issues for UI or other user-facing changes made by this pull request.