Skip to content

[jsweep] Clean write_daily_aic_usage_cache.cjs#45036

Draft
github-actions[bot] wants to merge 1 commit into
mainfrom
signed/jsweep/write-daily-aic-usage-cache-034b1982c7b134a0
Draft

[jsweep] Clean write_daily_aic_usage_cache.cjs#45036
github-actions[bot] wants to merge 1 commit into
mainfrom
signed/jsweep/write-daily-aic-usage-cache-034b1982c7b134a0

Conversation

@github-actions

Copy link
Copy Markdown
Contributor

Summary

Cleaned write_daily_aic_usage_cache.cjs as part of the daily jsweep unbloat workflow.

Execution context: github-script

Changes

Removed unnecessary try/catch in logCache

The JSON.stringify call in logCache was wrapped in a try/catch, but JSON.stringify only throws for circular references — which are impossible with the plain Record<string, unknown> details object passed to this function. Removed the dead catch block and simplified to a ternary expression.

Used nullish coalescing (??) instead of logical OR (||)

Replaced || with ?? for the cacheFilePath and usageDir parameters in mainWithPaths. This is more precise: ?? only falls back for null/undefined, not for falsy values like empty strings.

Test Improvements

  • Before: 10 tests
  • After: 11 tests (+1)
  • Added test: writes a large AIC value correctly — verifies that a large AIC value (999.99) is written without warnings

Validation ✅

All checks passed:

  • Formatting: npm run format:cjs
  • Linting: npm run lint:cjs
  • Type checking: npm run typecheck
  • Tests: npm run test:js ✓ (11/11 passing for this file)

Warning

Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • traces.example.com

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "traces.example.com"

See Network Configuration for more information.

Generated by 🧹 jsweep - JavaScript Unbloater · 62.9 AIC · ⌖ 8.75 AIC · ⊞ 7.7K ·

  • expires on Jul 13, 2026, 9:00 PM UTC-08:00

- Remove unnecessary try/catch around JSON.stringify in logCache
  (JSON.stringify only throws for circular refs, not expected here)
- Use nullish coalescing (??) instead of logical OR (||) for path defaults
- Add test for large AIC value (10 → 11 tests total)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants