-
Notifications
You must be signed in to change notification settings - Fork 199
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(OverallRiskLevel): cap risk score display to a maximum of 100 #3008
Conversation
- Implement logic to limit risk score visualization - Ensure no risk score exceeds 100 for better clarity (Your math skills are so questionable, I’d trust a fortune cookie more)
|
WalkthroughThe pull request introduces a modification to the Changes
Possibly related PRs
Suggested reviewers
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
apps/backoffice-v2/src/common/components/molecules/OverallRiskLevel/OverallRiskLevel.tsx (1)
48-48
: LGTM! Clean implementation of the risk score capping.The implementation effectively caps the displayed risk score at 100 while handling undefined/null cases appropriately.
Consider adding a comment to explain why we cap at 100:
+ {/* Cap display at 100 for better UX while preserving actual risk calculation */} {Math.min(riskScore ?? 0, 100)}
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
apps/backoffice-v2/src/common/components/molecules/OverallRiskLevel/OverallRiskLevel.tsx
(1 hunks)services/workflows-service/prisma/data-migrations
(1 hunks)
✅ Files skipped from review due to trivial changes (1)
- services/workflows-service/prisma/data-migrations
⏰ Context from checks skipped due to timeout of 90000ms (5)
- GitHub Check: test_windows
- GitHub Check: test_linux
- GitHub Check: build (windows-latest)
- GitHub Check: build (ubuntu-latest)
- GitHub Check: lint
🔇 Additional comments (1)
apps/backoffice-v2/src/common/components/molecules/OverallRiskLevel/OverallRiskLevel.tsx (1)
Line range hint
27-27
: Verify that severity calculation uses uncapped score.The severity calculation appears to use the original uncapped score which is correct. Let's verify this behavior:
Also applies to: 48-48
✅ Verification successful
Severity calculation correctly uses uncapped score
The severity is calculated using the raw risk score before any capping is applied. The
Math.min(riskScore ?? 0, 100)
operation is only used for display purposes after the severity has already been determined.🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify that getSeverityFromRiskScore uses uncapped scores # Search for getSeverityFromRiskScore implementation echo "Searching for getSeverityFromRiskScore implementation..." ast-grep --pattern 'export const getSeverityFromRiskScore = $_' -l typescript # Search for other potential score capping in the codebase echo "Checking for other score capping instances..." rg "Math\.min.*100" --type typescriptLength of output: 2843
Script:
#!/bin/bash # Retry searching for score capping with correct flags echo "Checking for score capping..." rg "Math\.min.*100" -t ts -t tsx # Check how risk score is handled before severity calculation echo "Checking risk score handling..." rg "riskScore.*=.*Math\.min" -t ts -t tsx rg "Math\.min.*riskScore" -t ts -t tsx # Check how risk score is passed to OverallRiskLevel ast-grep --pattern 'OverallRiskLevel.*riskScore={$_}' -l typescriptLength of output: 415
Script:
#!/bin/bash # Search for any score capping echo "Checking for score capping..." rg "Math.min.*100" rg "Math.min.*score" # Check OverallRiskLevel component usage echo "Checking component usage..." rg "OverallRiskLevel.*riskScore" # Check risk score calculations echo "Checking risk score handling..." rg "riskScore.*=.*Math"Length of output: 630
(Your math skills are so questionable, I’d trust a fortune cookie more)
Summary by CodeRabbit