Change from metric to rule
The SARIF that we are interpreting has moved away from using `metric` to the more general term, `rule`. We need to adapt our baseline lines of code counting to use `rule` as well.
This commit is contained in:
parent
8e3540bb01
commit
a2312a0bf3
6 changed files with 30 additions and 30 deletions
14
lib/analyze.js
generated
14
lib/analyze.js
generated
|
|
@ -158,15 +158,15 @@ async function injectLinesOfCode(sarifFile, language, locPromise) {
|
|||
const sarif = JSON.parse(fs.readFileSync(sarifFile, "utf8"));
|
||||
if (Array.isArray(sarif.runs)) {
|
||||
for (const run of sarif.runs) {
|
||||
const metricId = `${language}/summary/lines-of-code`;
|
||||
const ruleId = `${language}/summary/lines-of-code`;
|
||||
run.properties = run.properties || {};
|
||||
run.properties.metricResults = run.properties.metricResults || [];
|
||||
const metric = run.properties.metricResults.find(
|
||||
// the metric id can be in either of two places
|
||||
(m) => { var _a; return m.metricId === metricId || ((_a = m.metric) === null || _a === void 0 ? void 0 : _a.id) === metricId; });
|
||||
// only add the baseline value if the metric already exists
|
||||
if (metric) {
|
||||
metric.baseline = lineCounts[language];
|
||||
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];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue