Skip to content

refactor: make packageIsVerified() actually short-circuit - #101

Merged
kmturley merged 1 commit into
mainfrom
fix/package-is-verified-short-circuit
Jul 31, 2026
Merged

refactor: make packageIsVerified() actually short-circuit#101
kmturley merged 1 commit into
mainfrom
fix/package-is-verified-short-circuit

Conversation

@kmturley

Copy link
Copy Markdown
Member

Summary

  • The return inside pkgVersion.files.forEach() only exited that iteration's callback, not the outer function, so it kept scanning every remaining file even after verified was already false. Harmless today (files arrays are capped at 256 by the validator) but flagged as a nitpick in an internal spec-compliance audit.
  • Rewrote using files.every(), which is both the more direct expression of the "verified iff every file matches" semantic and actually short-circuits on the first non-matching file.
  • Also adds this function's first test coverage (previously only exercised indirectly through fixtures that all happened to be verified: true).

Test plan

  • npm run check passes (format, lint, build, tests — 207/207)
  • New tests: all-matching files → verified; one non-matching file → not verified

🤖 Generated with Claude Code

The `return` inside pkgVersion.files.forEach() only exited that
iteration's callback, not the outer function, so it kept scanning
every remaining file even after `verified` was already false.
Harmless today (files arrays are capped at 256 by the validator) but
flagged as a nitpick in an internal spec-compliance audit.

Rewrote using files.every(), which is both the more direct expression
of the "verified iff every file matches" semantic and actually
short-circuits on the first non-matching file. Also adds this
function's first test coverage (previously only exercised indirectly
through fixtures that all happened to be verified=true).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@kmturley
kmturley merged commit 1634bbc into main Jul 31, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant