Fix negative streak handling in getFreebuffStreakGlmWeeklyUnits - #1261
Fix negative streak handling in getFreebuffStreakGlmWeeklyUnits#1261pavankumar-vh wants to merge 1 commit into
Conversation
The function didn't validate that streak is non-negative. If streak was negative, Math.floor(streak / INTERVAL) would be negative, and Math.min with the positive max would return the negative value, resulting in a negative GLM bonus. Added Math.max(0, streak) to ensure streak is non-negative before processing. Also added a test case to verify the negative streak clamping behavior.
|
Good, focused fix. The core question is whether The test added is clear and directly verifies the fix (-1, -100, 0, 7, 14). Nice touch keeping the existing test style consistent with the file. One minor nit: consider using Small, well-scoped, has a test, easy to port. Recommend acceptance, though maintainers should double check whether negative streak is actually reachable in production to confirm this is fixing a real bug and not just a hypothetical. |
Overview
Fix negative streak handling in the
getFreebuffStreakGlmWeeklyUnitsfunction incommon/src/util/freebuff-streak.ts.Bug Description
The function didn't validate that streak is non-negative. If streak was negative,
Math.floor(streak / INTERVAL)would be negative, andMath.minwith the positive max would return the negative value, resulting in a negative GLM bonus.Fix
Added
Math.max(0, streak)to ensure streak is non-negative before processing.Testing
Added a new test case that verifies:
All 15 tests pass (including the new one).
Files Changed
common/src/util/freebuff-streak.ts- Added negative streak validationcommon/src/util/__tests__/freebuff-streak.test.ts- Added test coverageScope
This change only touches
common/which is an approved contribution area per the Contributing Guide.