Integrate codeql database unbundle#971
Conversation
Co-authored by: Marc Jaramillo mnj.webdeveloper@gmail.comm Co-authored by: Musab Guma'a mgsium@github.com
ef12f4f to
b22a869
Compare
aeisenberg
left a comment
There was a problem hiding this comment.
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.
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.
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.
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.
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.
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.
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'); | |
| } |
| progress, | ||
| token | ||
| token, | ||
| this.queryServer.cliServer |
There was a problem hiding this comment.
| this.queryServer.cliServer | |
| this?.queryServer.cliServer |
| if (!this.queryServer) { | ||
| throw new Error('Query server not started'); | ||
| } | ||
|
|
There was a problem hiding this comment.
See comment below, this is no longer needed
Co-authored by: Marc Jaramillo mnj.webdeveloper@gmail.com Co-authored by: Musab Guma'a mgsium@github.com
aeisenberg
left a comment
There was a problem hiding this comment.
Looks good. Let's ship it.
Fixes #1660
Checklist
@github/docs-content-codeqlhas been cc'd in all issues for UI or other user-facing changes made by this pull request.