Skip to content

refactor: pass each phase a context instead of shared loop state - #22

Merged
maxholman merged 7 commits into
masterfrom
refactor/size-rules
Sep 22, 2026
Merged

maxholman merged 7 commits into
masterfrom
refactor/size-rules

Conversation

@maxholman

@maxholman maxholman Bot commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

processOpenApiDocument held every operation's state in loop-local variables that later phases read out of the enclosing scope, so it could not be split while its parts shared that scope. Each phase is now a function over a context — DocumentContext per document, OperationContext per operation — and reads one value instead. The same split covers schemaToValidator, createValidatorForOperationInput, schemaToType and registerTypesFromSchema.

Every function oxlint flagged on max-statements, complexity or max-lines-per-function now meets the limits by extraction, with no disable comments and no rule changes.

Proof

Fixture regeneration changes no generated file. The only diff under __tests__/fixtures is the #generator stamp in each manifest, which hashes the generator sources.

maxholman and others added 7 commits September 21, 2026 21:25
schemaToValidator keeps the dispatch and hands each branch to a helper:
enum, type array, string, int64, number, combinators with the allOf
composer, and object. createValidatorForOperationInput builds its
schema pairs through module-level emitters parameterised on the object
kind and the key mapper.

Co-Authored-By: LLM <noreply@block65.dev>
The document phases are now functions over a DocumentContext: output
files, module preambles, component schemas, operations, client module,
validated module, hono module and the trailing type-argument trim.

Each operation builds an OperationShape record: its command class,
resolved parameters, the query, header, params and body type aliases,
and the input type. The record is what the type-argument and
constructor phases read, so the loop-local variables the old body
shared are declared once.

Co-Authored-By: LLM <noreply@block65.dev>
schemaToType hands each schema shape to a helper and spreads the type
it returns into the property structure. registerTypesFromSchema ends
every case through one registerAlias helper and takes its combinator
and named-string cases from their own functions.

Co-Authored-By: LLM <noreply@block65.dev>
Co-Authored-By: LLM <noreply@block65.dev>
…alike

OperationShape carried `parameters` as one nested group while the three
type aliases sat flat beside it, so every consumer re-paired them by
hand. The locations are now sibling pairs, like the body and input
fields already were: queryParameters/queryType, headerParameters/
headerType, pathParameters/pathType. `paramsType` becomes `pathType` so
each pair shares its prefix.

The per-document and per-operation contexts serve the same purpose, so
they are named the same way. OperationShape is now OperationContext, and
the variables are documentCtx and operationCtx.

Three comments go: two restated the declaration below them, one restated
a ternary. Where one carried a reason, the reason stays as a clause.

Co-Authored-By: LLM <noreply@block65.dev>
Only the `#generator` fingerprint moves. Every per-file content hash is
unchanged, so the emitted clients are byte-identical across the refactor.

Co-Authored-By: LLM <noreply@block65.dev>
`defineOverrides` already returns the array, so the spread rebuilt it.

Co-Authored-By: LLM <noreply@block65.dev>
@maxholman maxholman Bot changed the title refactor: bring the five oversized functions under the size rules refactor: pass each phase a context instead of shared loop state Sep 22, 2026
@maxholman
maxholman merged commit 0027bfc into master Sep 22, 2026
4 checks passed
@maxholman
maxholman Bot deleted the refactor/size-rules branch September 22, 2026 03:48
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