Refactored code of rule ordering

This commit is contained in:
VakarisZ 2021-01-14 12:17:34 +02:00
parent a818025f63
commit 761ed2ec43
1 changed files with 7 additions and 14 deletions

View File

@ -29,19 +29,12 @@ function compareRules(firstRule, secondRule) {
} }
function compareRuleStatuses(ruleStatusOne, ruleStatusTwo) { function compareRuleStatuses(ruleStatusOne, ruleStatusTwo) {
if (ruleStatusOne === ruleStatusTwo) { const severity_order = {
return 0; [STATUSES.STATUS_FAILED]: 1,
} else if (ruleStatusOne === STATUSES.STATUS_FAILED) { [STATUSES.STATUS_VERIFY]: 2,
return -1; [STATUSES.STATUS_PASSED]: 3,
} else if (ruleStatusTwo === STATUSES.STATUS_FAILED) { [STATUSES.STATUS_UNEXECUTED]: 4
return 1;
} else if (ruleStatusOne === STATUSES.STATUS_VERIFY) {
return -1;
} else if (ruleStatusTwo === STATUSES.STATUS_VERIFY) {
return 1;
} else if (ruleStatusOne === STATUSES.STATUS_PASSED) {
return -1;
} else if (ruleStatusTwo === STATUSES.STATUS_PASSED) {
return 1;
} }
return severity_order[ruleStatusOne] - severity_order[ruleStatusTwo]
} }