Skip to content

Commit ea990a3

Browse files
committed
Remove flags for CLI v2.6.2 and earlier
1 parent b45e925 commit ea990a3

6 files changed

Lines changed: 20 additions & 126 deletions

File tree

lib/analyze.js

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

lib/analyze.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/codeql.js

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

lib/codeql.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/analyze.ts

Lines changed: 4 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,7 @@ import * as yaml from "js-yaml";
88

99
import { DatabaseCreationTimings } from "./actions-util";
1010
import * as analysisPaths from "./analysis-paths";
11-
import {
12-
CodeQL,
13-
CODEQL_VERSION_COUNTS_LINES,
14-
CODEQL_VERSION_NEW_TRACING,
15-
getCodeQL,
16-
} from "./codeql";
11+
import { CodeQL, CODEQL_VERSION_NEW_TRACING, getCodeQL } from "./codeql";
1712
import * as configUtils from "./config-utils";
1813
import { countLoc } from "./count-loc";
1914
import { FeatureEnablement } from "./feature-flags";
@@ -221,10 +216,9 @@ export async function runQueries(
221216
let locPromise: Promise<Partial<Record<Language, number>>> = Promise.resolve(
222217
{}
223218
);
224-
const cliCanCountBaseline = await cliCanCountLoC();
225219
const countLocDebugMode =
226220
process.env["INTERNAL_CODEQL_ACTION_DEBUG_LOC"] || config.debugMode;
227-
if (!cliCanCountBaseline || countLocDebugMode) {
221+
if (countLocDebugMode) {
228222
// count the number of lines in the background
229223
locPromise = countLoc(
230224
path.resolve(),
@@ -346,20 +340,15 @@ export async function runQueries(
346340
sarifFile,
347341
config.debugMode
348342
);
349-
if (!cliCanCountBaseline) {
350-
await injectLinesOfCode(sarifFile, language, locPromise);
351-
}
352343
statusReport[`interpret_results_${language}_duration_ms`] =
353344
new Date().getTime() - startTimeInterpretResults;
354345
logger.endGroup();
355346
logger.info(analysisSummary);
356347
}
357-
if (!cliCanCountBaseline || countLocDebugMode) {
348+
if (countLocDebugMode) {
358349
printLinesOfCodeSummary(logger, language, await locPromise);
359350
}
360-
if (cliCanCountBaseline) {
361-
logger.info(await runPrintLinesOfCode(language));
362-
}
351+
logger.info(await runPrintLinesOfCode(language));
363352
} catch (e) {
364353
logger.info(String(e));
365354
if (e instanceof Error) {
@@ -394,13 +383,6 @@ export async function runQueries(
394383
);
395384
}
396385

397-
async function cliCanCountLoC() {
398-
return await util.codeQlVersionAbove(
399-
await getCodeQL(config.codeQLCmd),
400-
CODEQL_VERSION_COUNTS_LINES
401-
);
402-
}
403-
404386
async function runPrintLinesOfCode(language: Language): Promise<string> {
405387
const databasePath = util.getCodeQLDatabasePath(config, language);
406388
return await codeql.databasePrintBaseline(databasePath);
@@ -554,38 +536,6 @@ export async function runCleanup(
554536
logger.endGroup();
555537
}
556538

557-
async function injectLinesOfCode(
558-
sarifFile: string,
559-
language: Language,
560-
locPromise: Promise<Partial<Record<Language, number>>>
561-
) {
562-
const lineCounts = await locPromise;
563-
if (language in lineCounts) {
564-
const sarif = JSON.parse(fs.readFileSync(sarifFile, "utf8"));
565-
566-
if (Array.isArray(sarif.runs)) {
567-
for (const run of sarif.runs) {
568-
run.properties = run.properties || {};
569-
run.properties.metricResults = run.properties.metricResults || [];
570-
for (const metric of run.properties.metricResults) {
571-
// Baseline is inserted when matching rule has tag lines-of-code
572-
if (metric.rule && metric.rule.toolComponent) {
573-
const matchingRule =
574-
run.tool.extensions[metric.rule.toolComponent.index].rules[
575-
metric.rule.index
576-
];
577-
if (matchingRule.properties.tags?.includes("lines-of-code")) {
578-
metric.baseline = lineCounts[language];
579-
}
580-
}
581-
}
582-
}
583-
}
584-
585-
fs.writeFileSync(sarifFile, JSON.stringify(sarif));
586-
}
587-
}
588-
589539
function printLinesOfCodeSummary(
590540
logger: Logger,
591541
language: Language,

src/codeql.ts

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -246,12 +246,6 @@ const CODEQL_MINIMUM_VERSION = "2.6.3";
246246
* For convenience, please keep these in descending order. Once a version
247247
* flag is older than the oldest supported version above, it may be removed.
248248
*/
249-
const CODEQL_VERSION_RAM_FINALIZE = "2.5.8";
250-
const CODEQL_VERSION_DIAGNOSTICS = "2.5.6";
251-
const CODEQL_VERSION_METRICS = "2.5.5";
252-
const CODEQL_VERSION_GROUP_RULES = "2.5.5";
253-
const CODEQL_VERSION_SARIF_GROUP = "2.5.3";
254-
export const CODEQL_VERSION_COUNTS_LINES = "2.6.2";
255249
const CODEQL_VERSION_CUSTOM_QUERY_HELP = "2.7.1";
256250
const CODEQL_VERSION_LUA_TRACER_CONFIG = "2.10.0";
257251
export const CODEQL_VERSION_CONFIG_FILES = "2.10.1";
@@ -970,11 +964,10 @@ async function getCodeQLForCmd(
970964
"finalize",
971965
"--finalize-dataset",
972966
threadsFlag,
967+
memoryFlag,
973968
...getExtraOptionsFromEnv(["database", "finalize"]),
974969
databasePath,
975970
];
976-
if (await util.codeQlVersionAbove(this, CODEQL_VERSION_RAM_FINALIZE))
977-
args.push(memoryFlag);
978971
await toolrunnerErrorCatcher(cmd, args, errorMatchers);
979972
},
980973
async resolveLanguages() {
@@ -1077,20 +1070,14 @@ async function getCodeQLForCmd(
10771070
verbosityFlag,
10781071
`--output=${sarifFile}`,
10791072
addSnippetsFlag,
1073+
"--print-diagnostics-summary",
1074+
"--print-metrics-summary",
1075+
"--sarif-group-rules-by-pack",
10801076
...getExtraOptionsFromEnv(["database", "interpret-results"]),
10811077
];
1082-
if (await util.codeQlVersionAbove(this, CODEQL_VERSION_DIAGNOSTICS))
1083-
codeqlArgs.push("--print-diagnostics-summary");
1084-
if (await util.codeQlVersionAbove(this, CODEQL_VERSION_METRICS))
1085-
codeqlArgs.push("--print-metrics-summary");
1086-
if (await util.codeQlVersionAbove(this, CODEQL_VERSION_GROUP_RULES))
1087-
codeqlArgs.push("--sarif-group-rules-by-pack");
10881078
if (await util.codeQlVersionAbove(this, CODEQL_VERSION_CUSTOM_QUERY_HELP))
10891079
codeqlArgs.push("--sarif-add-query-help");
1090-
if (
1091-
automationDetailsId !== undefined &&
1092-
(await util.codeQlVersionAbove(this, CODEQL_VERSION_SARIF_GROUP))
1093-
) {
1080+
if (automationDetailsId !== undefined) {
10941081
codeqlArgs.push("--sarif-category", automationDetailsId);
10951082
}
10961083
if (

0 commit comments

Comments
 (0)