Fixing circular reference, adding prettier.
This commit is contained in:
+26
-19
@@ -1,24 +1,31 @@
|
||||
import { Changes } from './schemas'
|
||||
import { Severity, SEVERITIES } from './config'
|
||||
import {Changes} from './schemas'
|
||||
import {Severity, SEVERITIES} from './schemas'
|
||||
|
||||
export function filterChangesBySeverity(severity: Severity, changes: Changes): Changes {
|
||||
const severityIdx = SEVERITIES.indexOf(severity)
|
||||
export function filterChangesBySeverity(
|
||||
severity: Severity,
|
||||
changes: Changes
|
||||
): Changes {
|
||||
const severityIdx = SEVERITIES.indexOf(severity)
|
||||
|
||||
for (let change of changes) {
|
||||
if (change === undefined ||
|
||||
change.vulnerabilities === undefined ||
|
||||
change.vulnerabilities.length === 0) {
|
||||
continue
|
||||
}
|
||||
change.vulnerabilities = change.vulnerabilities.filter((vuln: any) => {
|
||||
const vulnIdx = SEVERITIES.indexOf(vuln.severity)
|
||||
if (vulnIdx <= severityIdx) {
|
||||
return true
|
||||
}
|
||||
})
|
||||
for (let change of changes) {
|
||||
if (
|
||||
change === undefined ||
|
||||
change.vulnerabilities === undefined ||
|
||||
change.vulnerabilities.length === 0
|
||||
) {
|
||||
continue
|
||||
}
|
||||
change.vulnerabilities = change.vulnerabilities.filter(vuln => {
|
||||
const vulnIdx = SEVERITIES.indexOf(vuln.severity)
|
||||
if (vulnIdx <= severityIdx) {
|
||||
return true
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// don't want to deal with changes with no vulnerabilities
|
||||
let filteredChanges = changes.filter((change: any) => change.vulnerabilities.length > 0)
|
||||
return filteredChanges
|
||||
// don't want to deal with changes with no vulnerabilities
|
||||
let filteredChanges = changes.filter(
|
||||
change => change.vulnerabilities.length > 0
|
||||
)
|
||||
return filteredChanges
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user