diff --git a/frontend/cypress/support/helper/scoringSupport.ts b/frontend/cypress/support/helper/scoringSupport.ts index dccd5600fe..c02502316b 100644 --- a/frontend/cypress/support/helper/scoringSupport.ts +++ b/frontend/cypress/support/helper/scoringSupport.ts @@ -101,31 +101,30 @@ function colorFromPercentage(percentage: number) { } function scoringValueFromPercentage(percentage: number): ScoringValue { - if (percentage >= 100) { - return { - failPercent: 0, - commitPercent: 0, - targetPercent: 0 - }; - } else if (percentage > 70) { - const targetPercent = (percentage - 70) * (100 / 30); - return { - failPercent: 100, - commitPercent: 100, - targetPercent: targetPercent - }; - } else if (percentage > 30) { - const commitPercent = (percentage - 30) * (100 / 40); - return { - failPercent: 100, - commitPercent: commitPercent, - targetPercent: -1 - }; + switch (true) { + case percentage >= 100: + return { + failPercent: 0, + commitPercent: 0, + targetPercent: 0 + }; + case percentage > 70: + return { + failPercent: 100, + commitPercent: 100, + targetPercent: (percentage - 70) * (100 / 30) + }; + case percentage > 30: + return { + failPercent: 100, + commitPercent: (percentage - 30) * (100 / 40), + targetPercent: -1 + }; + default: + return { + failPercent: percentage * (100 / 30), + commitPercent: -1, + targetPercent: -1 + }; } - const failPercent = percentage * (100 / 30); - return { - failPercent: failPercent, - commitPercent: -1, - targetPercent: -1 - }; }