Add maximum number of queries to run

Throw error if user tries to run more than that.
This commit is contained in:
Andrew Eisenberg
2020-06-22 08:14:38 -07:00
parent fabef96f08
commit 6ae6e91195

View File

@@ -444,7 +444,12 @@ async function activateWithInstalledDistribution(
commands.registerCommand(
'codeQL.runQueries',
async (_: Uri | undefined, multi: Uri[]) => {
const maxQueryCount = 20;
try {
const [files, dirFound] = await gatherQlFiles(multi.map(uri => uri.fsPath));
if (files.length > maxQueryCount) {
throw new Error(`You tried to run ${files.length} queries, but the maximum is ${maxQueryCount}. Try selecting fewer queries.`);
}
// warn user and display selected files when a directory is selected because some ql
// files may be hidden from the user.
if (dirFound) {
@@ -458,6 +463,9 @@ async function activateWithInstalledDistribution(
}
const queryUris = files.map(path => Uri.parse(`file:${path}`, true));
await Promise.all(queryUris.map(uri => compileAndRunQuery(false, uri)));
} catch (e) {
helpers.showAndLogErrorMessage(e.message);
}
}
)
);