Skip to content

Commit dc36689

Browse files
Check that the set of queries is non-empty at init time
1 parent 4896ba5 commit dc36689

6 files changed

Lines changed: 35 additions & 6 deletions

File tree

lib/config-utils.js

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/config-utils.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/config-utils.test.js

Lines changed: 8 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/config-utils.test.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/config-utils.test.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,9 @@ test("default queries are used", async t => {
224224
resolveQueriesArgs.push({queries, extraSearchPath});
225225
return {
226226
byLanguage: {
227-
'javascript': {},
227+
'javascript': {
228+
'foo.ql': {},
229+
},
228230
},
229231
noDeclaredLanguage: {},
230232
multipleDeclaredLanguages: {},
@@ -262,7 +264,11 @@ test("API client used when reading remote config", async t => {
262264
CodeQL.setCodeQL({
263265
resolveQueries: async function() {
264266
return {
265-
byLanguage: {},
267+
byLanguage: {
268+
'javascript': {
269+
'foo.ql': {},
270+
},
271+
},
266272
noDeclaredLanguage: {},
267273
multipleDeclaredLanguages: {},
268274
};

src/config-utils.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -577,6 +577,15 @@ async function loadConfig(configFile: string): Promise<Config> {
577577
});
578578
}
579579

580+
// The list of queries should not be empty for any language. If it is then
581+
// it is a user configuration error.
582+
for (const language of languages) {
583+
if (queries[language].length === 0) {
584+
throw new Error(`Did not detect any queries to analyze for ${language}. ` +
585+
"Please make sure that the default queries are enabled, or you are specifying queries to run.");
586+
}
587+
}
588+
580589
return {
581590
languages,
582591
queries,

0 commit comments

Comments
 (0)