Skip to content
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

Merged

Conversation

marcnjaramillo
Copy link
Contributor

@marcnjaramillo marcnjaramillo commented Oct 15, 2021

Fixes #1660

Checklist

  • CHANGELOG.md has been updated to incorporate all user visible changes made by this pull request.
  • Issues have been created for any UI or other user-facing changes made by this pull request.
  • @github/docs-content-codeql has been cc'd in all issues for UI or other user-facing changes made by this pull request.

@marcnjaramillo marcnjaramillo requested a review from a team as a code owner October 15, 2021 23:16
extensions/ql-vscode/CHANGELOG.md Outdated Show resolved Hide resolved
extensions/ql-vscode/CHANGELOG.md Show resolved Hide resolved
extensions/ql-vscode/src/databaseFetcher.ts Outdated Show resolved Hide resolved
@marcnjaramillo marcnjaramillo force-pushed the integrate-codeql-database-unbundle branch from ef12f4f to b22a869 Compare October 18, 2021 21:56
Copy link
Contributor

@aeisenberg aeisenberg left a 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.

Comment on lines 455 to 470
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
);
}
Copy link
Contributor

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.

Suggested change
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
);

Copy link
Contributor Author

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
    );
  };

Comment on lines 478 to 493
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
);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here

Suggested change
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
);

Copy link
Contributor Author

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
    );
  };

Copy link
Contributor

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.

Comment on lines 722 to 724
if (!this.queryServer) {
throw new Error('Query server not started');
}
Copy link
Contributor

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.

Suggested change
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
this.queryServer.cliServer
this?.queryServer.cliServer

Comment on lines 594 to 597
if (!this.queryServer) {
throw new Error('Query server not started');
}

Copy link
Contributor

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]
Copy link
Contributor

@aeisenberg aeisenberg left a 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.

@aeisenberg aeisenberg merged commit b8618aa into github:main Oct 19, 2021
@github github deleted a comment from antunn Feb 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants