Skip to content

Commit

Permalink
Removed unnecessary if statement from Comparator
Browse files Browse the repository at this point in the history
- Adjusted the number values of the severity levels object to start with 1 instead of 0.
- This removes the need for the long if statement previously used to handle N/A values.
  • Loading branch information
hawkishpolicy committed Dec 27, 2024
1 parent c562310 commit 2da4510
Showing 1 changed file with 6 additions and 20 deletions.
26 changes: 6 additions & 20 deletions frontend/src/pages/Vulnerabilities/Vulnerabilities.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -413,27 +413,13 @@ export const Vulnerabilities: React.FC<{ groupBy?: string }> = ({
flex: 0.5,
sortComparator: (v1, v2, cellParams1, cellParams2) => {
const severityLevels: Record<string, number> = {
'N/A': 0,
Low: 1,
Medium: 2,
High: 3,
Critical: 4,
Other: 5
'N/A': 1,
Low: 2,
Medium: 3,
High: 4,
Critical: 5,
Other: 6
};
if (
cellParams1.value === 'N/A' &&
cellParams2.value !== 'N/A' &&
cellParams2.value !== 'Other'
) {
return -1;
}
if (
cellParams2.value === 'N/A' &&
cellParams1.value !== 'N/A' &&
cellParams1.value !== 'Other'
) {
return 1;
}
return (
severityLevels[cellParams1.value] - severityLevels[cellParams2.value]
);
Expand Down

0 comments on commit 2da4510

Please sign in to comment.