Skip to content

Integrate codeql database unbundle#971

Merged
aeisenberg merged 4 commits intogithub:mainfrom
marcnjaramillo:integrate-codeql-database-unbundle
Oct 19, 2021
Merged

Integrate codeql database unbundle#971
aeisenberg merged 4 commits intogithub:mainfrom
marcnjaramillo:integrate-codeql-database-unbundle

Conversation

@marcnjaramillo
Copy link
Copy Markdown
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
Co-authored by: Marc Jaramillo mnj.webdeveloper@gmail.comm
Co-authored by: Musab Guma'a mgsium@github.com
@marcnjaramillo marcnjaramillo force-pushed the integrate-codeql-database-unbundle branch from ef12f4f to b22a869 Compare October 18, 2021 21:56
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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');
}

progress,
token
token,
this.queryServer.cliServer
Copy link
Copy Markdown
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
Copy Markdown
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 mnj.webdeveloper@gmail.com
Co-authored by: Musab Guma'a mgsium@github.com
Copy link
Copy Markdown
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