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

Do not artificially restrict the set of supported languages #779

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions src/analyze.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { runQueries } from "./analyze";
import { setCodeQL } from "./codeql";
import { Config } from "./config-utils";
import * as count from "./count-loc";
import { Language } from "./languages";
import { KnownLanguage } from "./languages";
import { getRunnerLogger } from "./logging";
import { setupTests, setupActionsVars } from "./testing-utils";
import * as util from "./util";
Expand All @@ -21,8 +21,8 @@ setupTests(test);
// and correct case of builtin or custom. Also checks the correct search
// paths are set in the database analyze invocation.
test("status report fields and search path setting", async (t) => {
const mockLinesOfCode = Object.values(Language).reduce((obj, lang, i) => {
// use a different line count for each language
const mockLinesOfCode = Object.values(KnownLanguage).reduce((obj, lang, i) => {
// use a different line count for each KnownLanguage
obj[lang] = i + 1;
return obj;
}, {});
Expand All @@ -35,21 +35,21 @@ test("status report fields and search path setting", async (t) => {
const addSnippetsFlag = "";
const threadsFlag = "";
const packs = {
[Language.cpp]: [
[KnownLanguage.cpp]: [
{
packName: "a/b",
version: clean("1.0.0")!,
},
],
[Language.java]: [
[KnownLanguage.java]: [
{
packName: "c/d",
version: clean("2.0.0")!,
},
],
};

for (const language of Object.values(Language)) {
for (const language of Object.values(KnownLanguage)) {
setCodeQL({
packDownload: async () => ({ packs: [] }),
databaseRunQueries: async (
Expand Down Expand Up @@ -203,7 +203,7 @@ test("status report fields and search path setting", async (t) => {

function verifyLineCounts(tmpDir: string) {
// eslint-disable-next-line github/array-foreach
Object.keys(Language).forEach((lang, i) => {
Object.keys(KnownLanguage).forEach((lang, i) => {
verifyLineCountForFile(path.join(tmpDir, `${lang}.sarif`), i + 1);
});
}
Expand Down Expand Up @@ -249,14 +249,14 @@ test("status report fields and search path setting", async (t) => {
version: "2.0.0",
},
];
for (const lang of Object.values(Language)) {
for (const lang of Object.values(KnownLanguage)) {
t.deepEqual(readContents(`${lang}-queries-builtin.qls`), qlsContent);
t.deepEqual(readContents(`${lang}-queries-custom-0.qls`), qlsContent);
t.deepEqual(readContents(`${lang}-queries-custom-1.qls`), qlsContent2);
const packSuiteName = `${lang}-queries-packs.qls`;
if (lang === Language.cpp) {
if (lang === KnownLanguage.cpp) {
t.deepEqual(readContents(packSuiteName), qlsPackContentCpp);
} else if (lang === Language.java) {
} else if (lang === KnownLanguage.java) {
t.deepEqual(readContents(packSuiteName), qlsPackContentJava);
} else {
t.false(
Expand Down
4 changes: 2 additions & 2 deletions src/analyze.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import * as analysisPaths from "./analysis-paths";
import { CODEQL_VERSION_COUNTS_LINES, getCodeQL } from "./codeql";
import * as configUtils from "./config-utils";
import { countLoc } from "./count-loc";
import { isScannedLanguage, Language } from "./languages";
import { isScannedLanguage, KnownLanguage, Language } from "./languages";
import { Logger } from "./logging";
import * as sharedEnv from "./shared-environment";
import * as util from "./util";
Expand Down Expand Up @@ -124,7 +124,7 @@ async function createdDBForScannedLanguages(
) {
logger.startGroup(`Extracting ${language}`);

if (language === Language.python) {
if (language === KnownLanguage.python) {
await setupPythonExtractor(logger);
}

Expand Down
Loading