Check that the set of queries is non-empty at init time
This commit is contained in:
parent
4896ba51da
commit
dc366899d2
6 changed files with 35 additions and 6 deletions
8
lib/config-utils.js
generated
8
lib/config-utils.js
generated
|
|
@ -439,6 +439,14 @@ async function loadConfig(configFile) {
|
|||
paths.push(validateAndSanitisePath(path, PATHS_PROPERTY, configFile));
|
||||
});
|
||||
}
|
||||
// The list of queries should not be empty for any language. If it is then
|
||||
// it is a user configuration error.
|
||||
for (const language of languages) {
|
||||
if (queries[language].length === 0) {
|
||||
throw new Error(`Did not detect any queries to analyze for ${language}. ` +
|
||||
"Please make sure that the default queries are enabled, or you are specifying queries to run.");
|
||||
}
|
||||
}
|
||||
return {
|
||||
languages,
|
||||
queries,
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
10
lib/config-utils.test.js
generated
10
lib/config-utils.test.js
generated
|
|
@ -200,7 +200,9 @@ ava_1.default("default queries are used", async (t) => {
|
|||
resolveQueriesArgs.push({ queries, extraSearchPath });
|
||||
return {
|
||||
byLanguage: {
|
||||
'javascript': {},
|
||||
'javascript': {
|
||||
'foo.ql': {},
|
||||
},
|
||||
},
|
||||
noDeclaredLanguage: {},
|
||||
multipleDeclaredLanguages: {},
|
||||
|
|
@ -231,7 +233,11 @@ ava_1.default("API client used when reading remote config", async (t) => {
|
|||
CodeQL.setCodeQL({
|
||||
resolveQueries: async function () {
|
||||
return {
|
||||
byLanguage: {},
|
||||
byLanguage: {
|
||||
'javascript': {
|
||||
'foo.ql': {},
|
||||
},
|
||||
},
|
||||
noDeclaredLanguage: {},
|
||||
multipleDeclaredLanguages: {},
|
||||
};
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -224,7 +224,9 @@ test("default queries are used", async t => {
|
|||
resolveQueriesArgs.push({queries, extraSearchPath});
|
||||
return {
|
||||
byLanguage: {
|
||||
'javascript': {},
|
||||
'javascript': {
|
||||
'foo.ql': {},
|
||||
},
|
||||
},
|
||||
noDeclaredLanguage: {},
|
||||
multipleDeclaredLanguages: {},
|
||||
|
|
@ -262,7 +264,11 @@ test("API client used when reading remote config", async t => {
|
|||
CodeQL.setCodeQL({
|
||||
resolveQueries: async function() {
|
||||
return {
|
||||
byLanguage: {},
|
||||
byLanguage: {
|
||||
'javascript': {
|
||||
'foo.ql': {},
|
||||
},
|
||||
},
|
||||
noDeclaredLanguage: {},
|
||||
multipleDeclaredLanguages: {},
|
||||
};
|
||||
|
|
|
|||
|
|
@ -577,6 +577,15 @@ async function loadConfig(configFile: string): Promise<Config> {
|
|||
});
|
||||
}
|
||||
|
||||
// The list of queries should not be empty for any language. If it is then
|
||||
// it is a user configuration error.
|
||||
for (const language of languages) {
|
||||
if (queries[language].length === 0) {
|
||||
throw new Error(`Did not detect any queries to analyze for ${language}. ` +
|
||||
"Please make sure that the default queries are enabled, or you are specifying queries to run.");
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
languages,
|
||||
queries,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue