Skip to content

Lower production code complexity limit to 12 - #1891

Merged
stefan-burke merged 6 commits into
mainfrom
reduce-biome-complexity-to-12
Jul 23, 2026
Merged

Lower production code complexity limit to 12#1891
stefan-burke merged 6 commits into
mainfrom
reduce-biome-complexity-to-12

Conversation

@stefan-burke

@stefan-burke stefan-burke commented Jul 23, 2026

Copy link
Copy Markdown
Member

What changed

  • Lowered the cognitive complexity limit for production TypeScript and TSX from 13 to 12. Tests and tooling stay at 13.
  • Split every production function above the new limit into smaller, named steps. This covers the 15 planned functions plus two catalog helpers that landed on main with the preceding change.
  • Kept shared behavior on one path, including package-line identification used by payment validation and pricing.
  • Load independent admin page sections together while preserving their declared display order.
  • Moved site-assignment failure reporting into its own small module. Notifications now share the logged error code, and invalid-month logs identify the affected listing.
  • Added and strengthened direct tests for the refactored admin, payment, booking, merge, site assignment, image, and page-rendering flows.

Why

Smaller functions make these important flows easier to read and change. The stricter check prevents complexity from growing back.

Verification

  • Pinned Deno 2.5.6: deno task precommit
  • Branch mutation gate: 1,626/1,626 meaningful mutants detected, 84 proven equivalents, 0 survivors
  • Review follow-up mutation checks: entity pages 60/60, site assignment 99/99, failure reporting 5/5, listing actions 137/137
  • Changed tests have no test-quality audit findings
  • Duplication remains at 0%

Summary by CodeRabbit

  • New Features

    • Added structured site-assignment failure reporting with improved logging and notifications.
    • Enhanced payment processing behaviors for replay/idempotency, pricing validation, and refund/booking conflict outcomes.
    • Improved catalog-transfer import validation and persistence for listings, groups, package relationships, and parent links.
    • Improved reservation ticket UI (listing rows, ticket header metadata, and display behavior).
    • Improved manual check-in keyboard navigation and submission feedback.
  • Bug Fixes

    • Improved booking capacity/cap-overflow detection, attendee merge decisions, and image resize averaging.
  • Tests

    • Expanded coverage across payments, catalog imports, reservations, check-in, attendee management, site assignment, and merge logic.

@coderabbitai

coderabbitai Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Important

Review skipped

No new commits to review since the last review.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 37537b1a-d5bf-440d-9e86-84b274a8704a

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

This PR refactors admin, payment-processing, booking, shared-data, merge, site-assignment, and reservation UI flows into focused helpers. It adds broad integration and unit coverage for payment outcomes, catalog imports, capacity rules, attendee merges, manual check-in, and reservation rendering.

Changes

Core refactors and behavioral coverage

Layer / File(s) Summary
Tooling and admin validation
biome.json, scripts/mutation/equivalent-mutants.txt, src/features/admin/*, test/features/admin/*
Tightens TypeScript complexity settings and refactors admin template loading, entity-page resolution, and catalog-transfer validation with expanded route, policy, persistence, and reference tests.
Payment processing and booking paths
src/features/api/payment-processing/*, src/shared/booking/*, test/features/api/payment-processing/*, test/shared/booking/*
Separates balance and new-booking processing, centralizes booking-path derivation, and covers replay, refunds, conflicts, package pricing, stale paths, and folding behavior.
Shared data and listing behavior
src/shared/catalog-fields/*, src/shared/db/attendees/*, src/shared/images/*, src/shared/listings-actions.ts, src/shared/site-assignment*, test/shared/*
Extracts projection, capacity, image, listing-validation, and site-assignment reporting helpers with focused boundary and contract coverage.
Attendee merge behavior
src/shared/merge/*, test/shared/merge/*
Decomposes merge-decision validation and adds coverage for booking application, money handling, cleanup, exact diffs, ledger repointing, labels, and validation errors.
Reservation and manual check-in UI
src/ui/client/admin/manual-checkin.ts, src/ui/templates/public/reservations/*, test/ui/*
Extracts reservation rendering helpers, standardizes combobox keyboard handling, and tests interaction, submission, fallback, iframe, package, and saved-form behavior.

Estimated code review effort: 5 (Critical) | ~120 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: lowering the production complexity limit to 12.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch reduce-biome-complexity-to-12
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch reduce-biome-complexity-to-12

Comment @coderabbitai help to get the list of available commands.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: fc7c89b299

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/shared/site-assignment.ts Outdated
Comment thread scripts/mutation/equivalent-mutants.txt

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
test/shared/merge/attendee-merge/apply.test.ts (1)

62-69: 📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win

Use saveConflictAnswerChoice at the initial setup too. The inline saveChoice pair at lines 113-114 duplicates the helper already reused later in this file.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@test/shared/merge/attendee-merge/apply.test.ts` around lines 62 - 69, Replace
the duplicated inline saveChoice calls in the initial setup with the existing
saveConflictAnswerChoice helper, passing the same target, source, and answers
values; preserve the setup behavior and reuse the helper already defined in the
test file.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@scripts/mutation/equivalent-mutants.txt`:
- Around line 40-44: Resolve the conflict in the equivalent-mutant manifest by
reconciling scripts/mutation/equivalent-mutants.txt with origin/main and
retaining every valid entry from both versions, including the listed ?? → ||
cases. Remove all conflict markers, then rerun merge-check and mutation
validation to confirm the manifest and PR are mergeable.

In `@src/features/admin/entity-pages.ts`:
- Around line 276-289: Update loadPageSections to load all active.sections
concurrently with Promise.all over a preferred curried functional utility from
`#fp`, replacing the sequential imperative loop while preserving section order and
the existing custom panel behavior.

In `@src/shared/site-assignment.ts`:
- Around line 89-105: Update SITE_ASSIGNMENT_FAILURE_REPORTS so each
notification value reuses the corresponding ErrorCode member instead of
duplicating its string literal, keeping code and notification synchronized for
builder_disabled, initial_months, and missing_tier.
- Around line 108-119: Update reportSiteAssignmentFailure to include
failure.listingId in the log detail when it is present, while preserving the
existing reason and skippedCount information and avoiding an empty or undefined
listing identifier for other failure reasons.

---

Outside diff comments:
In `@test/shared/merge/attendee-merge/apply.test.ts`:
- Around line 62-69: Replace the duplicated inline saveChoice calls in the
initial setup with the existing saveConflictAnswerChoice helper, passing the
same target, source, and answers values; preserve the setup behavior and reuse
the helper already defined in the test file.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: bd2a8e9a-c2d4-462a-91fd-85941b1a4ce3

📥 Commits

Reviewing files that changed from the base of the PR and between a70a953 and fc7c89b.

📒 Files selected for processing (66)
  • biome.json
  • scripts/mutation/equivalent-mutants.txt
  • src/features/admin/attendee-page-data.ts
  • src/features/admin/catalog-transfer/import.ts
  • src/features/admin/entity-pages.ts
  • src/features/api/payment-processing/index.ts
  • src/features/api/payment-processing/items.ts
  • src/features/api/payment-processing/package-pricing.ts
  • src/shared/booking/fold-tree.ts
  • src/shared/booking/signed-metadata.ts
  • src/shared/catalog-fields/definition.ts
  • src/shared/db/attendees/update.ts
  • src/shared/images/resize.ts
  • src/shared/listings-actions.ts
  • src/shared/merge/attendee-merge.ts
  • src/shared/site-assignment.ts
  • src/ui/client/admin/manual-checkin.ts
  • src/ui/templates/public/reservations/form.tsx
  • src/ui/templates/public/reservations/ticket-page.tsx
  • test/features/admin/attendee-page-data/activity-and-questions.test.ts
  • test/features/admin/attendee-page-data/contact-records.test.ts
  • test/features/admin/attendee-page-data/refunds-ui.test.ts
  • test/features/admin/attendee-page-data/template-data.test.ts
  • test/features/admin/attendee-page-data/warnings.test.ts
  • test/features/admin/catalog-transfer/import/fields.test.ts
  • test/features/admin/catalog-transfer/import/packages.test.ts
  • test/features/admin/catalog-transfer/import/persistence.test.ts
  • test/features/admin/catalog-transfer/import/policy.test.ts
  • test/features/admin/catalog-transfer/import/reachability.test.ts
  • test/features/admin/catalog-transfer/import/references.test.ts
  • test/features/admin/entity-pages.test.ts
  • test/features/api/payment-processing/index/balance.test.ts
  • test/features/api/payment-processing/index/booking.test.ts
  • test/features/api/payment-processing/index/conflicts.test.ts
  • test/features/api/payment-processing/index/helpers.ts
  • test/features/api/payment-processing/index/modifiers.test.ts
  • test/features/api/payment-processing/index/refunds.test.ts
  • test/features/api/payment-processing/items.test.ts
  • test/features/api/payment-processing/items/boundaries.test.ts
  • test/features/api/payment-processing/items/helpers.ts
  • test/features/api/payment-processing/package-pricing.test.ts
  • test/features/api/payment-processing/package-pricing/database.test.ts
  • test/shared/booking/fold-tree.test.ts
  • test/shared/booking/signed-metadata.test.ts
  • test/shared/catalog-fields/definition.test.ts
  • test/shared/db/attendees/update.test.ts
  • test/shared/images/resize.test.ts
  • test/shared/listings-actions.test.ts
  • test/shared/listings-actions/helpers.ts
  • test/shared/listings-actions/lifecycle.test.ts
  • test/shared/listings-actions/reachability.test.ts
  • test/shared/listings-actions/validation.test.ts
  • test/shared/merge/attendee-merge/apply-bookings.test.ts
  • test/shared/merge/attendee-merge/apply-money.test.ts
  • test/shared/merge/attendee-merge/apply.test.ts
  • test/shared/merge/attendee-merge/cleanup.test.ts
  • test/shared/merge/attendee-merge/diff.test.ts
  • test/shared/merge/attendee-merge/labels.test.ts
  • test/shared/merge/attendee-merge/repoint.test.ts
  • test/shared/merge/attendee-merge/validate.test.ts
  • test/shared/site-assignment/contracts.test.ts
  • test/ui/client/admin/manual-checkin/combobox.test.ts
  • test/ui/client/admin/manual-checkin/fixture.ts
  • test/ui/client/admin/manual-checkin/submission.test.ts
  • test/ui/templates/public/reservations/form.test.ts
  • test/ui/templates/public/reservations/ticket-page.test.ts

Comment thread scripts/mutation/equivalent-mutants.txt Outdated
Comment thread src/features/admin/entity-pages.ts
Comment thread src/shared/site-assignment.ts Outdated
Comment thread src/shared/site-assignment.ts Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@scripts/mutation/equivalent-mutants.txt`:
- Around line 1084-1085: Remove or relocate the orphaned schema-index note in
the equivalent-mutants manifest, unless the missing schema-index mutant records
can be added immediately beneath it. Keep the note adjacent to the mutant
entries it explains and ensure it does not remain before the payment-processing
section without associated records.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 8b141ef8-d4e4-4820-a19e-0d41635ac234

📥 Commits

Reviewing files that changed from the base of the PR and between fc7c89b and ad5a435.

📒 Files selected for processing (1)
  • scripts/mutation/equivalent-mutants.txt

Comment thread scripts/mutation/equivalent-mutants.txt Outdated
@stefan-burke

Copy link
Copy Markdown
Member Author

Addressed the remaining review-body feedback in 27a43cc: the initial answer-conflict setup now reuses saveConflictAnswerChoice, and the attendee-merge direct suite passes. The automated docstring-coverage warning is not a repository gate or house requirement; the project requires explicit exported return types and behavior tests instead, and the authoritative pinned deno task precommit is green.

@stefan-burke
stefan-burke added this pull request to the merge queue Jul 23, 2026
@stefan-burke
stefan-burke removed this pull request from the merge queue due to a manual request Jul 23, 2026
@stefan-burke

Copy link
Copy Markdown
Member Author

@codex review

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

@stefan-burke: I’ll review the latest changes on #1891.

✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Swish!

Reviewed commit: fd7f058289

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@stefan-burke
stefan-burke added this pull request to the merge queue Jul 23, 2026
Merged via the queue into main with commit 4653f64 Jul 23, 2026
3 checks passed
@stefan-burke
stefan-burke deleted the reduce-biome-complexity-to-12 branch July 23, 2026 09:14
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