Repository navigation
Conversation
Add averageUnitPrice, which divides the cart's total by its units and rejects an empty cart. Signed-off-by: Alejandro Mery <amery@apptly.co>
|
@coderabbitai pause |
|
@claude full review |
|
Note Reviews pausedUse the following commands to manage reviews:
Use the checkboxes below for quick actions:
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 30 minutes. View limit detailsLimit details: You’ve used the included review currently available. Review configuration: ⚙️ Run configuration
📒 Files selected for processing (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. Comment |
|
Claude finished @amery's task in 16s —— View job Full review of PR #25
Findings
AGENTS.md compliance: The new exported function has a JSDoc comment, so it follows the rule. CI: I didn't check CI results. |
| if (items.length === 0) { | ||
| throw new RangeError('items must not be empty'); | ||
| } | ||
| return totalItems(items) / items.length; |
There was a problem hiding this comment.
Bug: the function is documented as the average price per unit, but it divides the line-total sum by items.length (number of line items), not by the total quantity of units. totalItems returns Σ price × quantity, so the matching divisor is Σ quantity.
Example: [{price: 10, quantity: 3}] gives 30 / 1 = 30, but the average unit price is 10. With [{price: 10, quantity: 1}, {price: 20, quantity: 3}] it returns 35, not 17.5.
The empty check has the same problem: items with all-zero quantities pass it and then divide by zero, returning NaN.
Suggested fix: sum item.quantity across items, guard on that total being 0, and divide by it.
✅ Action performedReviews paused. |
|
@claude full review |
|
Claude finished @amery's task in 22s —— View job Full review of PR #25Finding (already posted inline, not duplicated): AGENTS.md compliance: No violations. I checked the root CI: |
Trial 5 of the full-review skill, from the
ameryfork: asking@claude full reviewhere should runmain's skill withoutmake, andpost a review. Adds
averageUnitPrice, which divides by the number ofitems rather than the number of units.