Skip to content

Lower the code complexity limit to 13 - #1887

Merged
stefan-burke merged 4 commits into
mainfrom
reduce-biome-complexity-to-13
Jul 22, 2026
Merged

Lower the code complexity limit to 13#1887
stefan-burke merged 4 commits into
mainfrom
reduce-biome-complexity-to-13

Conversation

@stefan-burke

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

Copy link
Copy Markdown
Member

Summary

  • Lower the allowed code complexity from 15 to 13 and simplify every function that crossed the new limit.
  • Move attendee line parsing into its own focused module.
  • Make the test-quality audit ignore lexical text when finding tests, assertions, and test boundaries.
  • Handle comments inside template substitutions and apostrophes in TSX text.
  • Validate feature choices with a schema and reject malformed ticket quantities in the browser.
  • Fix mixed package bookings, hosted card retries, and arrow defaults in type parameters.
  • Add direct regression tests for the changed behavior.

Review

  • Addressed the first four CodeRabbit threads in 1e0b812b.
  • Added deterministic direct audit coverage in 5551336f after CI exposed the executable shell as uncovered.
  • Addressed every CodeRabbit and Codex follow-up thread in fe599921, with fixes for three valid audit issues and checked evidence for five stale or incorrect claims.
  • Re-reviewed the feedback patches; no further concrete bugs or regressions were found.

Checks

  • 378 earlier targeted harness tests passed.
  • 99 focused test steps passed for the final feedback patch.
  • The changed lexer and pure audit model have 100% direct line and branch coverage.
  • The test-quality audit scans the real test tree without reporting its own lexical fixtures.
  • Targeted type checks and Biome checks passed.
  • deno task cpd passed with no duplication.
  • deno task precommit was not rerun, as requested.
  • Mutation tests were not run, as requested.

Summary by CodeRabbit

  • Bug Fixes

    • Improved hosted card-field handling by automatically choosing and retrying the first visible field across the page/frames.
    • Ticket quantity validation now recognizes both quantity_ and package_quantity_ inputs, including leading-zero values.
    • Attendee form handling now ignores invalid line entries and blocks unavailable child selections.
    • Administrative activity logs continue to redact sensitive values.
    • Ticket checkout targeting and paid-booking metadata are more reliably computed.
  • Quality Improvements

    • Refined admin listing rendering for child listings and improved attendee table sorting consistency.

@coderabbitai

coderabbitai Bot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

This PR refactors mutation execution, lexical and test-quality tooling, admin and booking flows, payment metadata, UI behavior, hosted card handling, shared validation, and related tests and configuration.

Changes

Mutation runner orchestration

Layer / File(s) Summary
Mutant evaluation stages
scripts/mutation/evaluate.ts, test/scripts/mutation-evaluate.test.ts
Evaluation separates static gates, asset rebuilding, test stages, integration handling, and cleanup through shared context helpers.
Concurrent batch control
scripts/mutation/execution.ts, test/scripts/mutation-execution.test.ts
Batch workers share execution context and stop subsequent batches after failures or timeouts.

Hosted card interaction

Layer / File(s) Summary
Visible card field actions
e2e-payments/src/providers/*, test/scripts/e2e-card-provider.test.ts
Hosted card selectors use an ordered visibility/action helper with retry behavior.
Selector and module contracts
e2e-payments/src/providers/card.ts, deno.json
Card selector keys are checked against CardDetails, and the e2e source receives a Deno import alias.

Code-quality tooling

Layer / File(s) Summary
Shared lexical and scanner traversal
scripts/typescript-lex.ts, test/lib/code-quality/*, scripts/mutation/generate.ts, scripts/run-tests.ts
Lexical skipping, AST child traversal, bracket tracking, and source snippet line calculation use extracted helpers.
Test-quality audit model
scripts/test-quality-audit-model.ts, scripts/test-quality-audit.ts, test/scripts/test-quality-audit-model.test.ts
Test declaration parsing, assertionless-test detection, weak-assertion detection, and diagnostics are centralized and tested.
Quality configuration
biome.json, TODO.md
The cognitive-complexity threshold is reduced and the detector follow-up entry is updated.

Application flow refactors

Layer / File(s) Summary
Admin actions and attendee parsing
src/features/admin/*, src/ui/templates/admin/attendee-form.tsx, related tests
Action errors are normalized, attendee line parsing moves to a dedicated module, and dependent imports/tests are updated.
Admin scanning, settings, and listing edges
src/features/admin/scanner.ts, src/features/admin/settings-features.ts, src/features/admin/listings-parents.ts
Scan processing, feature saving, and duplicated group-edge copying are organized through focused helpers.
Public payment metadata
src/features/public/ticket-payment.ts, src/features/public/ticket-submit.ts, related tests
Gallery-target selection and paid-booking metadata construction are extracted and covered for listing, group, allocation, and folded-listing cases.
Booking, structure, and UI behavior
src/shared/*, src/ui/*, related tests
Booking validation, drift checks, ledger validation, page-parent mapping, quantity enforcement, listing rows, and attendee sorting are refactored into reusable logic.

Test support maintenance

Layer / File(s) Summary
Test helper extraction and coverage assertions
test/lib/*, test/integration/*, test/scripts/*, test/test-utils/*
Database cleanup, i18n coverage, stalled-request simulation, fake DOM state, and activity-log assertions use focused helpers.

Estimated code review effort: 4 (Complex) | ~60 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately reflects one of the main changes: lowering the code complexity threshold from 15 to 13.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch reduce-biome-complexity-to-13
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch reduce-biome-complexity-to-13

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

@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

🤖 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/test-quality-audit.ts`:
- Around line 40-50: Update testBlockEnd to lexically skip comments, quoted
strings, and template literals—including escaped characters—so parentheses
inside them do not change depth; only count delimiters in executable code. Add a
regression case covering a test title containing “)” and verify the boundary
reaches the actual closing call delimiter without a false assertionless-test
finding.

In `@src/features/admin/attendee-form-model.ts`:
- Around line 341-415: Extract the SubmittedLine and LineResolver types plus
submittedLines, parseLine, and parseLines into a dedicated module, preserving
their current behavior and documentation. Update attendee-form-model.ts to
import and use parseLines, and move any required shared imports or type
references without changing parsing semantics.

In `@src/features/admin/settings-features.ts`:
- Around line 41-45: Replace the manual enabled-value comparison in the feature
settings handler with a Valibot picklist schema for "true" and "false"; parse
the value at this external boundary and preserve the existing errorRedirect
behavior for invalid input while using the validated result downstream.

In `@src/ui/client/admin/ticket-quantity-required.ts`:
- Around line 15-16: Update the quantity parsing in the ticket validation logic
around the total calculation to reject partially numeric input such as
“1invalid”; validate that the complete trimmed input is a valid positive
quantity before adding it to total. Add a regression test covering malformed
mixed numeric text.
🪄 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: b409b22f-a541-4f06-aabd-899d9eabfd56

📥 Commits

Reviewing files that changed from the base of the PR and between a52a0bf and 0f965af.

📒 Files selected for processing (42)
  • TODO.md
  • biome.json
  • deno.json
  • e2e-payments/src/providers/card.ts
  • e2e-payments/src/providers/visible-action.ts
  • scripts/mutation/evaluate.ts
  • scripts/mutation/execution.ts
  • scripts/mutation/generate.ts
  • scripts/run-tests.ts
  • scripts/test-quality-audit.ts
  • src/features/admin/actions.ts
  • src/features/admin/attendee-form-model.ts
  • src/features/admin/listings-parents.ts
  • src/features/admin/scanner.ts
  • src/features/admin/settings-features.ts
  • src/features/public/ticket-payment.ts
  • src/features/public/ticket-submit.ts
  • src/shared/booking/fold-tree.ts
  • src/shared/booking/signed-metadata.ts
  • src/shared/ledger/validate.ts
  • src/shared/site-pages/core.ts
  • src/ui/client/admin/ticket-quantity-required.ts
  • src/ui/templates/admin/listings/details.tsx
  • src/ui/templates/attendee-table.tsx
  • test/features/admin/attendee-form-model.test.ts
  • test/features/public/ticket-payment/packages.test.ts
  • test/features/public/ticket-submit.test.ts
  • test/integration/test-utils/stubs-and-mocks.test.ts
  • test/lib/code-quality/detectors.ts
  • test/lib/code-quality/duplicate-types.test.ts
  • test/lib/code-quality/relative-import.ts
  • test/lib/db/migration-restore/helpers.ts
  • test/lib/i18n-coverage.test.ts
  • test/lib/server-misc-admin-handlers.test.ts
  • test/scripts/e2e-card-provider.test.ts
  • test/scripts/mutation-evaluate.test.ts
  • test/scripts/mutation-execution.test.ts
  • test/scripts/static-cdn-publish.test.ts
  • test/test-utils/fake-dom.ts
  • test/ui/client/admin/ticket-quantity-required.test.ts
  • test/ui/templates/admin/listings/overview/detail-roster.test.ts
  • test/ui/templates/attendee-table/values.test.ts

Comment thread scripts/test-quality-audit.ts Outdated
Comment thread src/features/admin/attendee-form-model.ts Outdated
Comment thread src/features/admin/settings-features.ts
Comment thread src/ui/client/admin/ticket-quantity-required.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: 2

🤖 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/typescript-lex.ts`:
- Around line 28-35: Update the template-substitution scanner around scanText so
comment contents are skipped before processing brace characters: ignore both
block comments and line comments, including any “}” within them, while
preserving depth updates for actual substitution braces. Add direct lexer
regressions covering comment-contained braces and the nested-template case
described, and audit related scanners for the same premature-termination
behavior.

In `@src/ui/client/admin/ticket-quantity-required.ts`:
- Around line 15-17: Update the quantity parsing in the ticket-quantity guard to
use the same lexical rule as child-selection, accepting only "0" or integers
without leading zeros; preserve the existing positive safe-integer accumulation
behavior and add a regression case covering leading-zero inputs such as "01" and
"0001".
🪄 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: 59ddc6be-3909-4148-b551-b625a232419c

📥 Commits

Reviewing files that changed from the base of the PR and between 0f965af and 1e0b812.

📒 Files selected for processing (16)
  • scripts/test-quality-audit.ts
  • scripts/typescript-lex.ts
  • src/features/admin/attendee-form-lines.ts
  • src/features/admin/attendee-form-model.ts
  • src/features/admin/servicing/form-model.ts
  • src/features/admin/settings-features.ts
  • src/ui/client/admin/ticket-quantity-required.ts
  • src/ui/templates/admin/attendee-form.tsx
  • test/integration/servicing/form-schema.test.ts
  • test/lib/code-quality/callsite-scanners.test.ts
  • test/lib/code-quality/detectors.ts
  • test/lib/code-quality/duplicate-types.test.ts
  • test/lib/code-quality/relative-import.ts
  • test/scripts/test-quality-audit.test.ts
  • test/ui/client/admin/ticket-quantity-required.test.ts
  • test/ui/templates/admin/dashboard.test.ts

Comment thread scripts/typescript-lex.ts
Comment thread src/ui/client/admin/ticket-quantity-required.ts

@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: 1e0b812b76

ℹ️ 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 scripts/test-quality-audit.ts Outdated
Comment thread scripts/typescript-lex.ts Outdated
Comment thread scripts/test-quality-audit.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: 3

🤖 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 `@deno.json`:
- Line 19: Update the "typecheck" script in deno.json to remove the standalone
scripts/screenshots.ts entry while retaining scripts/screenshots/**/*.ts and all
other existing typecheck paths.

In `@scripts/test-quality-audit-model.ts`:
- Around line 68-78: The assertionless-test filter in findAssertionlessTests
matches raw test content, allowing comments or strings containing expect/assert
text to hide findings. Use the same lexical blanking applied by
testBlockEnd/testBlockRanges before applying EXPECT_PATTERN, and add a
regression test in the test-quality-audit-model suite with only a comment or
string mention, preserving full branch coverage.

In `@test/scripts/test-quality-audit-model.test.ts`:
- Around line 20-33: Split the test around auditTestContent into two focused
tests: one covering fake test declarations inside strings, templates, line
comments, and block comments, and another covering weak-assertion text in those
lexical contexts. Keep the real passing test only in the declaration-focused
fixture and give each test an assertion that isolates its respective behavior.
🪄 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: d179fe0e-3a3d-465a-bd72-98296bb1f113

📥 Commits

Reviewing files that changed from the base of the PR and between 1e0b812 and 5551336.

📒 Files selected for processing (4)
  • deno.json
  • scripts/test-quality-audit-model.ts
  • scripts/test-quality-audit.ts
  • test/scripts/test-quality-audit-model.test.ts

Comment thread deno.json
Comment thread scripts/test-quality-audit-model.ts
Comment thread test/scripts/test-quality-audit-model.test.ts
@stefan-burke
stefan-burke added this pull request to the merge queue Jul 22, 2026

@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: fe599921d5

ℹ️ 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".

/** Add metadata needed after a paid booking returns from the provider. Child
* allocations always travel with the payment. A single parent's redirect only
* needs an explicit override when folding added a child listing. */
export const withPaidBookingMetadata = (

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Keep paid metadata helper private

No production module imports this new export; it is only called inside this file and by the new test/features/public/ticket-submit.test.ts, so the public surface exists just to unit-test a private helper. That is the same test-only API pattern the repo asks us to delete rather than allow-list; keep the helper private and cover it through the submit/paid path that production calls.

AGENTS.md reference: AGENTS.md:L64-L64

Useful? React with 👍 / 👎.

Comment thread scripts/typescript-lex.ts
Comment on lines +6 to +8
const isQuoteAt = (content: string, index: number): boolean =>
isQuote(content[index]) &&
!(content[index] === "'" && isIdentifierChar(content[index - 1]));

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Do not skip valid quotes after keywords

This apostrophe heuristic applies to all TypeScript, not just JSX text, so valid strings that start immediately after an identifier-like keyword are no longer blanked. For example, an assertionless test containing return'expect(1).toBe(1)' leaves the quoted expect( visible to blankSpans(..., true), causing the test-quality audit to treat fixture text as a real assertion; the TSX-text exception needs to be narrower than every identifier-preceded apostrophe.

Useful? React with 👍 / 👎.


/** The page header whose gallery is shown: a group takes priority, otherwise a
* sole listing supplies the header. A multi-listing page has no one gallery. */
export const ticketGalleryTarget = (

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Keep gallery target helper private

This helper is only used by getTicketContext in this module and by the new package test, with no production importer elsewhere, so exporting it creates another test-only surface rather than a real shared API. Please keep it private and exercise it through the public ticket-context path instead of exporting an internal calculation solely for tests.

AGENTS.md reference: AGENTS.md:L64-L64

Useful? React with 👍 / 👎.

Merged via the queue into main with commit c373431 Jul 22, 2026
3 checks passed
@stefan-burke
stefan-burke deleted the reduce-biome-complexity-to-13 branch July 22, 2026 17:57
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