Skip to content

Comments

ref: Combine multiple reduce operations into single pass#207

Merged
dcramer merged 1 commit intomainfrom
warden-sweep/1984f16e/code-simplifier-154faa58
Feb 23, 2026
Merged

ref: Combine multiple reduce operations into single pass#207
dcramer merged 1 commit intomainfrom
warden-sweep/1984f16e/code-simplifier-154faa58

Conversation

@dcramer
Copy link
Member

@dcramer dcramer commented Feb 22, 2026

Combine 5 consecutive .reduce() calls on the same array in aggregateUsage() into a single pass that accumulates all fields at once.

The function previously iterated the reportsWithUsage array 5 times (once per field: inputTokens, outputTokens, cacheReadInputTokens, cacheCreationInputTokens, costUSD). Refactored to a single reduce with a seed object.

Automated fix for Warden finding code-simplifier-154faa58 (medium, detected by code-simplifier).

This PR was auto-generated by a Warden Sweep (run 1984f16e).
The finding has been validated through automated deep tracing,
but human confirmation is requested as this is batch work.

Warden finding code-simplifier-154faa58
Severity: medium

Co-Authored-By: Warden <noreply@getsentry.com>
@dcramer dcramer added the warden Automated fix from Warden Sweep label Feb 22, 2026
@dcramer dcramer marked this pull request as ready for review February 23, 2026 07:25
@dcramer dcramer merged commit d82c33a into main Feb 23, 2026
12 checks passed
@dcramer dcramer deleted the warden-sweep/1984f16e/code-simplifier-154faa58 branch February 23, 2026 07:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

warden Automated fix from Warden Sweep

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant