Zhou
Zhou MingxuanHead of R&D
Quality gate blocked
  • Coverage is 55% below 60%

Fix the cart badge quantity

hanshop-mobilefix/cart-badgeLin Xi · 2026-06-05 15:02
Changed files(1)
src/cart/badge.ts+21
11 export function badgeCount(items: CartItem[]) {
2- return items.length;
2+ // Sum quantities, not line items
3+ return items.reduce((sum, item) => sum + item.qty, 0);
A
AI reviewerAIMinor
The reduce initializer is correct, but item.qty may be undefined in imported data. Use item.qty ?? 0 to keep the total numeric.
34 }
AI review process

Review the plan

  1. Develop a review planThis small cart-counting change is routed to Sonnet for a focused logic review.

Output

0 problems

The old implementation counted line items rather than purchased units. The new reduction fixes that behavior, but must treat a missing qty as zero. Coverage remains below the gate and needs boundary cases.

96
A
Quality score

Summary of issues

    Critical0
    Major0
    Minor1
    Info0
Lead reviewer modelClaude Sonnet 4.6
Code coverage55%
Review cost¥0.007