in eng/tools/lint-diff/src/correlateResults.ts [154:197]
export function getNewItems(
before: LintDiffViolation[],
after: LintDiffViolation[],
): [LintDiffViolation[], LintDiffViolation[]] {
const newItems = [];
const existingItems = [];
for (const afterViolation of after) {
let errorIsNew = true;
// Always treat fatal errors as new
if (afterViolation.level.toLowerCase() === "fatal") {
newItems.push(afterViolation);
continue;
}
// Search through "before" to find a matching violation
for (const beforeViolation of before) {
if (
beforeViolation.level == afterViolation.level &&
beforeViolation.code == afterViolation.code &&
beforeViolation.message == afterViolation.message &&
beforeViolation.source?.length == afterViolation.source?.length &&
beforeViolation.source?.length &&
afterViolation.source?.length &&
isSameSources(beforeViolation.source, afterViolation.source) &&
arrayIsEqual(beforeViolation.details?.jsonpath, afterViolation.details?.jsonpath)
) {
errorIsNew = false;
existingItems.push(afterViolation);
// Only need to find one match
break;
}
}
// If no match is found, add to new
if (errorIsNew) {
newItems.push(afterViolation);
}
}
return [newItems, existingItems];
}