Remove state from the filtering function.
This commit is contained in:
16
dist/index.js
generated
vendored
16
dist/index.js
generated
vendored
@@ -13671,21 +13671,23 @@ exports.filterChangesBySeverity = void 0;
|
||||
const schemas_1 = __nccwpck_require__(1129);
|
||||
function filterChangesBySeverity(severity, changes) {
|
||||
const severityIdx = schemas_1.SEVERITIES.indexOf(severity);
|
||||
let filteredChanges = [];
|
||||
for (let change of changes) {
|
||||
if (change === undefined ||
|
||||
change.vulnerabilities === undefined ||
|
||||
change.vulnerabilities.length === 0) {
|
||||
continue;
|
||||
}
|
||||
change.vulnerabilities = change.vulnerabilities.filter(vuln => {
|
||||
const vulnIdx = schemas_1.SEVERITIES.indexOf(vuln.severity);
|
||||
if (vulnIdx <= severityIdx) {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
let fChange = Object.assign(Object.assign({}, change), { vulnerabilities: change.vulnerabilities.filter(vuln => {
|
||||
const vulnIdx = schemas_1.SEVERITIES.indexOf(vuln.severity);
|
||||
if (vulnIdx <= severityIdx) {
|
||||
return true;
|
||||
}
|
||||
}) });
|
||||
filteredChanges.push(fChange);
|
||||
}
|
||||
// don't want to deal with changes with no vulnerabilities
|
||||
let filteredChanges = changes.filter(change => change.vulnerabilities.length > 0);
|
||||
filteredChanges = filteredChanges.filter(change => change.vulnerabilities.length > 0);
|
||||
return filteredChanges;
|
||||
}
|
||||
exports.filterChangesBySeverity = filterChangesBySeverity;
|
||||
|
||||
2
dist/index.js.map
generated
vendored
2
dist/index.js.map
generated
vendored
File diff suppressed because one or more lines are too long
@@ -6,7 +6,7 @@ export function filterChangesBySeverity(
|
||||
changes: Changes
|
||||
): Changes {
|
||||
const severityIdx = SEVERITIES.indexOf(severity)
|
||||
|
||||
let filteredChanges = []
|
||||
for (let change of changes) {
|
||||
if (
|
||||
change === undefined ||
|
||||
@@ -15,16 +15,21 @@ export function filterChangesBySeverity(
|
||||
) {
|
||||
continue
|
||||
}
|
||||
change.vulnerabilities = change.vulnerabilities.filter(vuln => {
|
||||
const vulnIdx = SEVERITIES.indexOf(vuln.severity)
|
||||
if (vulnIdx <= severityIdx) {
|
||||
return true
|
||||
}
|
||||
})
|
||||
|
||||
let fChange = {
|
||||
...change,
|
||||
vulnerabilities: change.vulnerabilities.filter(vuln => {
|
||||
const vulnIdx = SEVERITIES.indexOf(vuln.severity)
|
||||
if (vulnIdx <= severityIdx) {
|
||||
return true
|
||||
}
|
||||
})
|
||||
}
|
||||
filteredChanges.push(fChange)
|
||||
}
|
||||
|
||||
// don't want to deal with changes with no vulnerabilities
|
||||
let filteredChanges = changes.filter(
|
||||
filteredChanges = filteredChanges.filter(
|
||||
change => change.vulnerabilities.length > 0
|
||||
)
|
||||
return filteredChanges
|
||||
|
||||
Reference in New Issue
Block a user