Repository navigation
Fix Leaderboard: convert NaN into 0% - #1190
Conversation
WalkthroughA check was added to the Changes
Suggested labels
Suggested reviewers
Poem
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
npm error Exit handler never called! 📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ Context from checks skipped due to timeout of 90000ms (1)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. 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.
Actionable comments posted: 0
🧹 Nitpick comments (1)
src/client/graphics/layers/Leaderboard.ts (1)
283-290: UseNumber.isNaN& guard early for clarityGood call adding the NaN →
"0%"fallback.
Two micro-improvements keep the code idiomatic:
- Prefer
Number.isNaNover the globalisNaN. The global version silently coerces non-numbers, which can hide bugs.- Bail out before the range comparisons so the intent (“invalid value ⇒ 0%”) is immediately visible.
function formatPercentage(value: number): string { const perc = value * 100; + // Guard: invalid number + if (Number.isNaN(perc)) return "0%"; + if (perc > 99.5) return "100%"; if (perc < 0.01) return "0%"; if (perc < 0.1) return perc.toPrecision(1) + "%"; - if (isNaN(perc)) return "0%"; return perc.toPrecision(2) + "%"; }Very small change, but it reads nicer and avoids an unnecessary coercion.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
src/client/graphics/layers/Leaderboard.ts(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: Deploy to openfront.dev
## Description: In edge cases, where all land is fallout, Owned % could be NaN%. Have it converted to 0% in such cases. https://discord.com/channels/1359946986937258015/1383735051195514880 BEFORE: <img width="1059" alt="Before" src="https://github.com/user-attachments/assets/a84bffe4-4a96-4175-897f-68be33778653" /> AFTER: It's a little hard to test (especially when currently you can't get in the old build menu and the new radial menu doesn't let you nuke yourself). But the code speaks for itself i hope. ## Please complete the following: - [x] I have added screenshots for all UI updates - [x] I process any text displayed to the user through translateText() and I've added it to the en.json file - [x] I have added relevant tests to the test directory - [x] I confirm I have thoroughly tested these changes and take full responsibility for any bugs introduced - [x] I understand that submitting code with bugs that could have been caught through manual testing blocks releases and new features for all contributors ## Please put your Discord username so you can be contacted if a bug or regression is found: tryout33
In edge cases, where all land is fallout, Owned % could be NaN%. Have it converted to 0% in such cases. https://discord.com/channels/1359946986937258015/1383735051195514880 BEFORE: <img width="1059" alt="Before" src="https://github.com/user-attachments/assets/a84bffe4-4a96-4175-897f-68be33778653" /> AFTER: It's a little hard to test (especially when currently you can't get in the old build menu and the new radial menu doesn't let you nuke yourself). But the code speaks for itself i hope. - [x] I have added screenshots for all UI updates - [x] I process any text displayed to the user through translateText() and I've added it to the en.json file - [x] I have added relevant tests to the test directory - [x] I confirm I have thoroughly tested these changes and take full responsibility for any bugs introduced - [x] I understand that submitting code with bugs that could have been caught through manual testing blocks releases and new features for all contributors regression is found: tryout33
Description:
In edge cases, where all land is fallout, Owned % could be NaN%. Have it converted to 0% in such cases.
https://discord.com/channels/1359946986937258015/1383735051195514880
BEFORE:

AFTER:
It's a little hard to test (especially when currently you can't get in the old build menu and the new radial menu doesn't let you nuke yourself). But the code speaks for itself i hope.
Please complete the following:
Please put your Discord username so you can be contacted if a bug or regression is found:
tryout33