mirror of
https://github.com/github/codeql-action.git
synced 2026-01-03 13:10:06 +08:00
Remove unneeded version guards
This commit is contained in:
@@ -303,16 +303,6 @@ const EXTRACTION_DEBUG_MODE_VERBOSITY = "progress++";
|
||||
* flag is older than the oldest supported version above, it may be removed.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Versions 2.14.2+ of the CodeQL CLI support language-specific baseline configuration.
|
||||
*/
|
||||
export const CODEQL_VERSION_LANGUAGE_BASELINE_CONFIG = "2.14.2";
|
||||
|
||||
/**
|
||||
* Versions 2.14.4+ of the CodeQL CLI support language aliasing.
|
||||
*/
|
||||
export const CODEQL_VERSION_LANGUAGE_ALIASING = "2.14.4";
|
||||
|
||||
/**
|
||||
* Versions 2.15.0+ of the CodeQL CLI support new analysis summaries.
|
||||
*/
|
||||
@@ -471,6 +461,7 @@ export function setCodeQL(partialCodeql: Partial<CodeQL>): CodeQL {
|
||||
betterResolveLanguages: resolveFunction(
|
||||
partialCodeql,
|
||||
"betterResolveLanguages",
|
||||
async () => ({ aliases: {}, extractors: {} }),
|
||||
),
|
||||
resolveQueries: resolveFunction(partialCodeql, "resolveQueries"),
|
||||
resolveBuildEnvironment: resolveFunction(
|
||||
@@ -602,14 +593,7 @@ export async function getCodeQLForCmd(
|
||||
extraArgs.push(`--qlconfig-file=${qlconfigFile}`);
|
||||
}
|
||||
|
||||
if (
|
||||
await util.codeQlVersionAtLeast(
|
||||
this,
|
||||
CODEQL_VERSION_LANGUAGE_BASELINE_CONFIG,
|
||||
)
|
||||
) {
|
||||
extraArgs.push("--calculate-language-specific-baseline");
|
||||
}
|
||||
extraArgs.push("--calculate-language-specific-baseline");
|
||||
|
||||
if (await isSublanguageFileCoverageEnabled(config, this)) {
|
||||
extraArgs.push("--sublanguage-file-coverage");
|
||||
@@ -638,7 +622,7 @@ export async function getCodeQLForCmd(
|
||||
"--db-cluster",
|
||||
config.dbLocation,
|
||||
`--source-root=${sourceRoot}`,
|
||||
...(await getLanguageAliasingArguments(this)),
|
||||
"--extractor-include-aliases",
|
||||
...extraArgs,
|
||||
...getExtraOptionsFromEnv(["database", "init"], {
|
||||
ignoringOptions: ["--overwrite"],
|
||||
@@ -758,7 +742,7 @@ export async function getCodeQLForCmd(
|
||||
"languages",
|
||||
"--format=betterjson",
|
||||
"--extractor-options-verbosity=4",
|
||||
...(await getLanguageAliasingArguments(this)),
|
||||
"--extractor-include-aliases",
|
||||
...getExtraOptionsFromEnv(["resolve", "languages"]),
|
||||
];
|
||||
const output = await runCli(cmd, codeqlArgs);
|
||||
@@ -801,7 +785,7 @@ export async function getCodeQLForCmd(
|
||||
"resolve",
|
||||
"build-environment",
|
||||
`--language=${language}`,
|
||||
...(await getLanguageAliasingArguments(this)),
|
||||
"--extractor-include-aliases",
|
||||
...getExtraOptionsFromEnv(["resolve", "build-environment"]),
|
||||
];
|
||||
if (workingDir !== undefined) {
|
||||
@@ -1065,7 +1049,7 @@ export async function getCodeQLForCmd(
|
||||
"extractor",
|
||||
"--format=json",
|
||||
`--language=${language}`,
|
||||
...(await getLanguageAliasingArguments(this)),
|
||||
"--extractor-include-aliases",
|
||||
...getExtraOptionsFromEnv(["resolve", "extractor"]),
|
||||
],
|
||||
{
|
||||
@@ -1336,15 +1320,6 @@ export function getGeneratedCodeScanningConfigPath(config: Config): string {
|
||||
return path.resolve(config.tempDir, "user-config.yaml");
|
||||
}
|
||||
|
||||
async function getLanguageAliasingArguments(codeql: CodeQL): Promise<string[]> {
|
||||
if (
|
||||
await util.codeQlVersionAtLeast(codeql, CODEQL_VERSION_LANGUAGE_ALIASING)
|
||||
) {
|
||||
return ["--extractor-include-aliases"];
|
||||
}
|
||||
return [];
|
||||
}
|
||||
|
||||
async function isSublanguageFileCoverageEnabled(
|
||||
config: Config,
|
||||
codeql: CodeQL,
|
||||
|
||||
@@ -6,14 +6,13 @@ import * as yaml from "js-yaml";
|
||||
import * as semver from "semver";
|
||||
|
||||
import * as api from "./api-client";
|
||||
import { CodeQL, CODEQL_VERSION_LANGUAGE_ALIASING } from "./codeql";
|
||||
import { CodeQL } from "./codeql";
|
||||
import { Feature, FeatureEnablement } from "./feature-flags";
|
||||
import { Language, parseLanguage } from "./languages";
|
||||
import { Logger } from "./logging";
|
||||
import { RepositoryNwo } from "./repository";
|
||||
import { downloadTrapCaches } from "./trap-caching";
|
||||
import {
|
||||
codeQlVersionAtLeast,
|
||||
GitHubVersion,
|
||||
prettyPrintPack,
|
||||
ConfigurationError,
|
||||
@@ -317,7 +316,7 @@ export async function getLanguages(
|
||||
|
||||
logger.info(`Automatically detected languages: ${languages.join(", ")}`);
|
||||
} else {
|
||||
const aliases = await getLanguageAliases(codeQL);
|
||||
const aliases = (await codeQL.betterResolveLanguages()).aliases;
|
||||
if (aliases) {
|
||||
languages = languages.map((lang) => aliases[lang] || lang);
|
||||
}
|
||||
@@ -352,19 +351,6 @@ export async function getLanguages(
|
||||
return parsedLanguages;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the set of languages supported by CodeQL, along with their aliases if supported by the
|
||||
* version of the CLI.
|
||||
*/
|
||||
export async function getLanguageAliases(
|
||||
codeql: CodeQL,
|
||||
): Promise<{ [alias: string]: string } | undefined> {
|
||||
if (await codeQlVersionAtLeast(codeql, CODEQL_VERSION_LANGUAGE_ALIASING)) {
|
||||
return (await codeql.betterResolveLanguages()).aliases;
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the set of languages in the current repository without checking to
|
||||
* see if these languages are actually supported by CodeQL.
|
||||
|
||||
@@ -524,29 +524,6 @@ async function run() {
|
||||
core.exportVariable("CODEQL_EXTRACTOR_JAVA_AGENT_DISABLE_KOTLIN", "true");
|
||||
}
|
||||
|
||||
const kotlinLimitVar =
|
||||
"CODEQL_EXTRACTOR_KOTLIN_OVERRIDE_MAXIMUM_VERSION_LIMIT";
|
||||
if (!(await codeQlVersionAtLeast(codeql, "2.14.4"))) {
|
||||
core.exportVariable(kotlinLimitVar, "1.9.20");
|
||||
}
|
||||
|
||||
if (
|
||||
config.languages.includes(Language.java) &&
|
||||
// Java Lombok support is enabled by default for >= 2.14.4
|
||||
(await codeQlVersionAtLeast(codeql, "2.14.0")) &&
|
||||
!(await codeQlVersionAtLeast(codeql, "2.14.4"))
|
||||
) {
|
||||
const envVar = "CODEQL_EXTRACTOR_JAVA_RUN_ANNOTATION_PROCESSORS";
|
||||
if (process.env[envVar]) {
|
||||
logger.info(
|
||||
`Environment variable ${envVar} already set. Not en/disabling CodeQL Java Lombok support`,
|
||||
);
|
||||
} else {
|
||||
logger.info("Enabling CodeQL Java Lombok support");
|
||||
core.exportVariable(envVar, "true");
|
||||
}
|
||||
}
|
||||
|
||||
if (config.languages.includes(Language.cpp)) {
|
||||
const envVar = "CODEQL_EXTRACTOR_CPP_TRAP_CACHING";
|
||||
if (process.env[envVar]) {
|
||||
|
||||
@@ -1,35 +1,16 @@
|
||||
import { CODEQL_VERSION_LANGUAGE_ALIASING, getCodeQL } from "./codeql";
|
||||
import { parseLanguage } from "./languages";
|
||||
import { getCodeQL } from "./codeql";
|
||||
import { Logger } from "./logging";
|
||||
import * as util from "./util";
|
||||
|
||||
export async function runResolveBuildEnvironment(
|
||||
cmd: string,
|
||||
logger: Logger,
|
||||
workingDir: string | undefined,
|
||||
languageInput: string,
|
||||
language: string,
|
||||
) {
|
||||
logger.startGroup(
|
||||
`Attempting to resolve build environment for ${languageInput}`,
|
||||
);
|
||||
logger.startGroup(`Attempting to resolve build environment for ${language}`);
|
||||
|
||||
const codeql = await getCodeQL(cmd);
|
||||
|
||||
let language = languageInput;
|
||||
// If the CodeQL CLI version in use supports language aliasing, give the CLI the raw language
|
||||
// input. Otherwise, parse the language input and give the CLI the parsed language.
|
||||
if (
|
||||
!(await util.codeQlVersionAtLeast(codeql, CODEQL_VERSION_LANGUAGE_ALIASING))
|
||||
) {
|
||||
const parsedLanguage = parseLanguage(languageInput)?.toString();
|
||||
if (parsedLanguage === undefined) {
|
||||
throw new util.ConfigurationError(
|
||||
`Did not recognize the language '${languageInput}'.`,
|
||||
);
|
||||
}
|
||||
language = parsedLanguage;
|
||||
}
|
||||
|
||||
if (workingDir !== undefined) {
|
||||
logger.info(`Using ${workingDir} as the working directory.`);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user