From 2e71e02553637cb3797506a6a342ae8c874d7f29 Mon Sep 17 00:00:00 2001 From: Edoardo Pirovano Date: Thu, 26 Aug 2021 13:46:22 +0100 Subject: [PATCH] Remove old baseline LoC injection --- lib/analyze.js | 12 +-------- lib/analyze.js.map | 2 +- lib/analyze.test.js | 50 +++------------------------------- lib/analyze.test.js.map | 2 +- lib/count-loc.js | 24 +---------------- lib/count-loc.js.map | 2 +- src/analyze.test.ts | 60 +++-------------------------------------- src/analyze.ts | 16 ++--------- src/count-loc.ts | 26 ------------------ 9 files changed, 15 insertions(+), 179 deletions(-) diff --git a/lib/analyze.js b/lib/analyze.js index 55054b4cc1..df88f1d6b6 100644 --- a/lib/analyze.js +++ b/lib/analyze.js @@ -233,24 +233,14 @@ exports.runCleanup = runCleanup; async function injectLinesOfCode(sarifFile, language, locPromise) { var _a; const lineCounts = await locPromise; - const idPrefix = count_loc_1.getIdPrefix(language); if (language in lineCounts) { const sarif = JSON.parse(fs.readFileSync(sarifFile, "utf8")); if (Array.isArray(sarif.runs)) { for (const run of sarif.runs) { - // Old style: Baseline is inserted when rule ID has suffix /summary/lines-of-code - const ruleId = `${idPrefix}/summary/lines-of-code`; run.properties = run.properties || {}; run.properties.metricResults = run.properties.metricResults || []; - const rule = run.properties.metricResults.find( - // the rule id can be in either of two places - (r) => { var _a; return r.ruleId === ruleId || ((_a = r.rule) === null || _a === void 0 ? void 0 : _a.id) === ruleId; }); - // only add the baseline value if the rule already exists - if (rule) { - rule.baseline = lineCounts[language]; - } - // New style: Baseline is inserted when matching rule has tag lines-of-code for (const metric of run.properties.metricResults) { + // Baseline is inserted when matching rule has tag lines-of-code if (metric.rule && metric.rule.toolComponent) { const matchingRule = run.tool.extensions[metric.rule.toolComponent.index].rules[metric.rule.index]; if ((_a = matchingRule.properties.tags) === null || _a === void 0 ? void 0 : _a.includes("lines-of-code")) { diff --git a/lib/analyze.js.map b/lib/analyze.js.map index 8905903a24..2dce4fee8f 100644 --- a/lib/analyze.js.map +++ b/l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AG,CAAC,UAAU,CAAC,aAAa,IAAI,EAAE,CAAC;gBAClE,KAAK,MAAM,MAAM,IAAI,GAAG,CAAC,UAAU,CAAC,aAAa,EAAE;oBACjD,gEAAgE;oBAChE,IAAI,MAAM,CAAC,IAAI,IAAI,MAAM,CAAC,IAAI,CAAC,aAAa,EAAE;wBAC5C,MAAM,YAAY,GAChB,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,KAAK,CACxD,MAAM,CAAC,IAAI,CAAC,KAAK,CAClB,CAAC;wBACJ,IAAI,MAAA,YAAY,CAAC,UAAU,CAAC,IAAI,0CAAE,QAAQ,CAAC,eAAe,CAAC,EAAE;4BAC3D,MAAM,CAAC,QAAQ,GAAG,UAAU,CAAC,QAAQ,CAAC,CAAC;yBACxC;qBACF;iBACF;aACF;SACF;QAED,EAAE,CAAC,aAAa,CAAC,SAAS,EAAE,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC;KACpD;AACH,CAAC;AAED,SAAS,uBAAuB,CAC9B,MAAc,EACd,QAAkB,EAClB,UAA6C;IAE7C,IAAI,QAAQ,IAAI,UAAU,EAAE;QAC1B,MAAM,CAAC,IAAI,CACT,yBAAyB,UAAU,CAAC,QAAQ,CAAC,sBAAsB,QAAQ,GAAG,CAC/E,CAAC;KACH;AACH,CAAC"} \ No newline at end of file diff --git a/lib/analyze.test.js b/lib/analyze.test.js index 5b3fab5033..11f2dd940f 100644 --- a/lib/analyze.test.js +++ b/lib/analyze.test.js @@ -30,7 +30,6 @@ const semver_1 = require("semver"); const sinon = __importStar(require("sinon")); const analyze_1 = require("./analyze"); const codeql_1 = require("./codeql"); -const count_loc_1 = require("./count-loc"); const count = __importStar(require("./count-loc")); const languages_1 = require("./languages"); const logging_1 = require("./logging"); @@ -76,31 +75,7 @@ ava_1.default("status report fields and search path setting", async (t) => { databaseInterpretResults: async (_db, _queriesRun, sarifFile) => { fs.writeFileSync(sarifFile, JSON.stringify({ runs: [ - // variant 1 uses ruleId - { - properties: { - metricResults: [ - { - ruleId: `${count_loc_1.getIdPrefix(language)}/summary/lines-of-code`, - value: 123, - }, - ], - }, - }, - // variant 2 uses rule.id - { - properties: { - metricResults: [ - { - rule: { - id: `${count_loc_1.getIdPrefix(language)}/summary/lines-of-code`, - }, - value: 123, - }, - ], - }, - }, - // variant 3 references a rule with the lines-of-code tag + // references a rule with the lines-of-code tag, so baseline should be injected { tool: { extensions: [ @@ -199,29 +174,12 @@ ava_1.default("status report fields and search path setting", async (t) => { function verifyLineCounts(tmpDir) { // eslint-disable-next-line github/array-foreach Object.keys(languages_1.Language).forEach((lang, i) => { - verifyLineCountForFile(lang, path.join(tmpDir, `${lang}.sarif`), i + 1); + verifyLineCountForFile(path.join(tmpDir, `${lang}.sarif`), i + 1); }); } - function verifyLineCountForFile(lang, filePath, lineCount) { - const idPrefix = count_loc_1.getIdPrefix(lang); + function verifyLineCountForFile(filePath, lineCount) { const sarif = JSON.parse(fs.readFileSync(filePath, "utf8")); t.deepEqual(sarif.runs[0].properties.metricResults, [ - { - ruleId: `${idPrefix}/summary/lines-of-code`, - value: 123, - baseline: lineCount, - }, - ]); - t.deepEqual(sarif.runs[1].properties.metricResults, [ - { - rule: { - id: `${idPrefix}/summary/lines-of-code`, - }, - value: 123, - baseline: lineCount, - }, - ]); - t.deepEqual(sarif.runs[2].properties.metricResults, [ { rule: { index: 0, @@ -234,7 +192,7 @@ ava_1.default("status report fields and search path setting", async (t) => { }, ]); // when the rule doesn't exist, it should not be added - t.deepEqual(sarif.runs[3].properties.metricResults, []); + t.deepEqual(sarif.runs[1].properties.metricResults, []); } function verifyQuerySuites(tmpDir) { const qlsContent = [ diff --git a/lib/analyze.test.js.map b/lib/analyze.test.js.map index 5e2233332c..b1b586c872 100644 --- a/lib/analyze.test.js.map +++ b/lib/analyze.test.js.map @@ -1 +1 @@ -{"version":3,"file":"analyze.test.js","sourceRoot":"","sources":["../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YACvE,MAAM,aAAa,GAAG,GAAG,IAAI,oBAAoB,CAAC;YAClD,IAAI,IAAI,KAAK,oBAAQ,CAAC,GAAG,EAAE;gBACzB,CAAC,CAAC,SAAS,CAAC,YAAY,CAAC,aAAa,CAAC,EAAE,iBAAiB,CAAC,CAAC;aAC7D;iBAAM,IAAI,IAAI,KAAK,oBAAQ,CAAC,IAAI,EAAE;gBACjC,CAAC,CAAC,SAAS,CAAC,YAAY,CAAC,aAAa,CAAC,EAAE,kBAAkB,CAAC,CAAC;aAC9D;iBAAM;gBACL,CAAC,CAAC,KAAK,CACL,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,kBAAkB,EAAE,aAAa,CAAC,CAAC,CACpE,CAAC;aACH;SACF;QAED,SAAS,YAAY,CAAC,IAAY;YAChC,MAAM,CAAC,GAAG,EAAE,CAAC,YAAY,CACvB,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,kBAAkB,EAAE,IAAI,CAAC,EAC3C,MAAM,CACP,CAAC;YACF,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;YAEf,OAAO,IAAI,CAAC,IAAI,CACd,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,kBAAkB,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,CACrE,CAAC;QACJ,CAAC;IACH,CAAC;AACH,CAAC,CAAC,CAAC"} \ No newline at end of file diff --git a/lib/count-loc.js b/lib/count-loc.js index b5d39301b1..3c0e7838a1 100644 --- a/lib/count-loc.js +++ b/lib/count-loc.js @@ -1,9 +1,8 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -exports.countLoc = exports.getIdPrefix = void 0; +exports.countLoc = void 0; const github_linguist_1 = require("github-linguist"); const languages_1 = require("./languages"); -const util_1 = require("./util"); // Map from linguist language names to language prefixes used in the action and codeql const linguistToMetrics = { c: languages_1.Language.cpp, @@ -23,27 +22,6 @@ const nameToLinguist = Object.entries(linguistToMetrics).reduce((obj, [key, name obj[name].push(key); return obj; }, {}); -function getIdPrefix(language) { - switch (language) { - case languages_1.Language.cpp: - return "cpp"; - case languages_1.Language.csharp: - return "cs"; - case languages_1.Language.go: - return "go"; - case languages_1.Language.java: - return "java"; - case languages_1.Language.javascript: - return "js"; - case languages_1.Language.python: - return "py"; - case languages_1.Language.ruby: - return "rb"; - default: - util_1.assertNever(language); - } -} -exports.getIdPrefix = getIdPrefix; /** * Count the lines of code of the specified language using the include * and exclude glob paths. diff --git a/lib/count-loc.js.map b/lib/count-loc.js.map index fb95eb8612..5864946dde 100644 --- a/lib/count-loc.js.map +++ b/lib/count-loc.js.map @@ -1 +1 @@ -{"version":3,"file":"count-loc.js","sourceRoot":"","sources":["../src/count-loc.ts"],"names":[],"mappings":";;;AAAA,qDAAyC;AAEzC,2CAAuC;AAEvC,iCAAqC;AAKrC,sFAAsF;AACtF,MAAM,iBAAiB,GAA6B;IAClD,CAAC,EAAE,oBAAQ,CAAC,GAAG;IACf,KAAK,EAAE,oBAAQ,CAAC,GAAG;IACnB,IAAI,EAAE,oBAAQ,CAAC,MAAM;IACrB,EAAE,EAAE,oBAAQ,CAAC,EAAE;IACf,IAAI,EAAE,oBAAQ,CAAC,IAAI;IACnB,UAAU,EAAE,oBAAQ,CAAC,UAAU;IAC/B,MAAM,EAAE,oBAAQ,CAAC,MAAM;IACvB,IAAI,EAAE,oBAAQ,CAAC,IAAI;IACnB,UAAU,EAAE,oBAAQ,CAAC,UAAU;CAChC,CAAC;AAEF,MAAM,cAAc,GAAG,MAAM,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAC,MAAM,CAC7D,CAAC,GAAG,EAAE,CAAC,GAAG,EAAE,IAAI,CAAC,EAAE,EAAE;IACnB,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE;QACd,GAAG,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC;KAChB;IACD,GAAG,CAAC,IAAI,CAAC,CAAC,IAAI,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AC;QACpD,IAAI,eAAe,IAAI,WAAW,CAAC,QAAQ,CAAC,eAAe,CAAC,EAAE;YAC5D,GAAG,CAAC,eAAe,CAAC,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC,CAAC;SAC3D;QACD,OAAO,GAAG,CAAC;IACb,CAAC,EACD,EAA8B,CAC/B,CAAC;IAEF,IAAI,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,MAAM,EAAE;QAClC,MAAM,CAAC,KAAK,CAAC,sBAAsB,CAAC,CAAC;QACrC,KAAK,MAAM,CAAC,QAAQ,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE;YAC1D,MAAM,CAAC,KAAK,CAAC,KAAK,QAAQ,KAAK,KAAK,EAAE,CAAC,CAAC;SACzC;KACF;SAAM;QACL,MAAM,CAAC,IAAI,CACT,2EAA2E;YACzE,gEAAgE;YAChE,4EAA4E;YAC5E,4EAA4E;YAC5E,2EAA2E;YAC3E,6EAA6E;YAC7E,2CAA2C,CAC9C,CAAC;KACH;IAED,OAAO,UAAU,CAAC;AACpB,CAAC;AA9CD,4BA8CC"} \ No newline at end of file diff --git a/src/analyze.test.ts b/src/analyze.test.ts index 82fb247412..c73159d1fe 100644 --- a/src/analyze.test.ts +++ b/src/analyze.test.ts @@ -9,7 +9,6 @@ import * as sinon from "sinon"; import { runQueries } from "./analyze"; import { setCodeQL } from "./codeql"; import { Config } from "./config-utils"; -import { getIdPrefix } from "./count-loc"; import * as count from "./count-loc"; import { Language } from "./languages"; import { getRunnerLogger } from "./logging"; @@ -68,33 +67,7 @@ test("status report fields and search path setting", async (t) => { sarifFile, JSON.stringify({ runs: [ - // variant 1 uses ruleId - { - properties: { - metricResults: [ - { - ruleId: `${getIdPrefix( - language - )}/summary/lines-of-code`, - value: 123, - }, - ], - }, - }, - // variant 2 uses rule.id - { - properties: { - metricResults: [ - { - rule: { - id: `${getIdPrefix(language)}/summary/lines-of-code`, - }, - value: 123, - }, - ], - }, - }, - // variant 3 references a rule with the lines-of-code tag + // references a rule with the lines-of-code tag, so baseline should be injected { tool: { extensions: [ @@ -231,38 +204,13 @@ 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) => { - verifyLineCountForFile( - lang as Language, - path.join(tmpDir, `${lang}.sarif`), - i + 1 - ); + verifyLineCountForFile(path.join(tmpDir, `${lang}.sarif`), i + 1); }); } - function verifyLineCountForFile( - lang: Language, - filePath: string, - lineCount: number - ) { - const idPrefix = getIdPrefix(lang); + function verifyLineCountForFile(filePath: string, lineCount: number) { const sarif = JSON.parse(fs.readFileSync(filePath, "utf8")); t.deepEqual(sarif.runs[0].properties.metricResults, [ - { - ruleId: `${idPrefix}/summary/lines-of-code`, - value: 123, - baseline: lineCount, - }, - ]); - t.deepEqual(sarif.runs[1].properties.metricResults, [ - { - rule: { - id: `${idPrefix}/summary/lines-of-code`, - }, - value: 123, - baseline: lineCount, - }, - ]); - t.deepEqual(sarif.runs[2].properties.metricResults, [ { rule: { index: 0, @@ -275,7 +223,7 @@ test("status report fields and search path setting", async (t) => { }, ]); // when the rule doesn't exist, it should not be added - t.deepEqual(sarif.runs[3].properties.metricResults, []); + t.deepEqual(sarif.runs[1].properties.metricResults, []); } function verifyQuerySuites(tmpDir: string) { diff --git a/src/analyze.ts b/src/analyze.ts index 78d0c4ff2a..cd1272bf1c 100644 --- a/src/analyze.ts +++ b/src/analyze.ts @@ -7,7 +7,7 @@ import * as yaml from "js-yaml"; import * as analysisPaths from "./analysis-paths"; import { getCodeQL } from "./codeql"; import * as configUtils from "./config-utils"; -import { countLoc, getIdPrefix } from "./count-loc"; +import { countLoc } from "./count-loc"; import { isScannedLanguage, Language } from "./languages"; import { Logger } from "./logging"; import * as sharedEnv from "./shared-environment"; @@ -415,27 +415,15 @@ async function injectLinesOfCode( locPromise: Promise>> ) { const lineCounts = await locPromise; - const idPrefix = getIdPrefix(language); if (language in lineCounts) { const sarif = JSON.parse(fs.readFileSync(sarifFile, "utf8")); if (Array.isArray(sarif.runs)) { for (const run of sarif.runs) { - // Old style: Baseline is inserted when rule ID has suffix /summary/lines-of-code - const ruleId = `${idPrefix}/summary/lines-of-code`; run.properties = run.properties || {}; run.properties.metricResults = run.properties.metricResults || []; - const rule = run.properties.metricResults.find( - // the rule id can be in either of two places - (r) => r.ruleId === ruleId || r.rule?.id === ruleId - ); - // only add the baseline value if the rule already exists - if (rule) { - rule.baseline = lineCounts[language]; - } - - // New style: Baseline is inserted when matching rule has tag lines-of-code for (const metric of run.properties.metricResults) { + // Baseline is inserted when matching rule has tag lines-of-code if (metric.rule && metric.rule.toolComponent) { const matchingRule = run.tool.extensions[metric.rule.toolComponent.index].rules[ diff --git a/src/count-loc.ts b/src/count-loc.ts index 1b317121b3..549f07d703 100644 --- a/src/count-loc.ts +++ b/src/count-loc.ts @@ -2,10 +2,6 @@ import { LocDir } from "github-linguist"; import { Language } from "./languages"; import { Logger } from "./logging"; -import { assertNever } from "./util"; - -// Language IDs used by codeql when specifying its metrics. -export type IdPrefix = "cpp" | "cs" | "go" | "java" | "js" | "py" | "rb"; // Map from linguist language names to language prefixes used in the action and codeql const linguistToMetrics: Record = { @@ -31,28 +27,6 @@ const nameToLinguist = Object.entries(linguistToMetrics).reduce( {} as Record ); -export function getIdPrefix(language: Language): IdPrefix { - switch (language) { - case Language.cpp: - return "cpp"; - case Language.csharp: - return "cs"; - case Language.go: - return "go"; - case Language.java: - return "java"; - case Language.javascript: - return "js"; - case Language.python: - return "py"; - case Language.ruby: - return "rb"; - - default: - assertNever(language); - } -} - /** * Count the lines of code of the specified language using the include * and exclude glob paths.