Skip to content

chore(quality): the cognitive-complexity findings of the local SonarQube and IDE round - #57

Merged
acn-ericlaw merged 1 commit into
mainfrom
chore/complexity-round-2026-11-16
Nov 16, 2026
Merged

acn-ericlaw merged 1 commit into
mainfrom
chore/complexity-round-2026-11-16

Conversation

@acn-ericlaw

Copy link
Copy Markdown
Collaborator

What

The cognitive-complexity findings of the local SonarQube and IDE round of 2026-11-16, fixed with no behaviour change.
Seven functions the scanner measured above its threshold of 15 are split along their natural seams: the Event API host
reads the x-ttl bound in _ttl, delivers an RPC in _deliver, builds an interceptor's envelope in _handler_event
and renders a stream segment through _classify_segment (the shape the Node twin's classifySegment already had); the
OTLP response decoder reads a response field, the partial_success block and its fields in _response_field,
_partial_success_block and _partial_success_field; the span mapper computes the start time, the status and the
attributes in _start_unix_nano, _span_status and _span_attributes; the ISO-8601 parser validates the date-time
fields in _date_time_fields and reads the fraction in _fraction_nanos; the LLM helper validates one tool in _tool
and the shape of a first or a later turn in _check_turn_shape. Every check runs in the order it did and raises the
message it did, so the shared vector files pass unchanged. Measured before and after with the cognitive-complexity
package, which gives Sonar's numbers on six of the seven (Sonar's before, the package's after):

Function Before After New helpers
server.handle_event 18 11 _ttl 2, _deliver 4
server._dispatch_interceptor 16 11 _handler_event 6
server._stream_segments 17 9 _classify_segment 7
otlp.partial_success 43 7 _response_field 3, _partial_success_block 5, _partial_success_field 10
span.span_from_dataset 23 7 _start_unix_nano 2, _span_status 3, _span_attributes 5
span.parse_iso8601_nanos 16 7 _date_time_fields 6, _fraction_nanos 4
llm_helper._tools 22 2 _tool 11
llm_helper.prepare_loop 16 5 _check_turn_shape 8

The IDE nits beside them: the exporter binds its lazy session through a local the checker can narrow, the MCP binding
builds its unknown-key list from strings (the join overload complaint) and names the error in its shutdown warning (the
broad-clause inspection accepts a used exception), "deployment" in a docstring, and Eric's removal of the envelope
codec's cast is kept behind a one-line pyright: ignore carrying the rationale. CHANGELOG Unreleased Changed 7.
ruff clean, basedpyright 0 errors, pytest 410 passed, 64 skipped; nothing else in the pack measures above 13.

Why

The second batch of Eric's local scan: the first round (#56) left the cognitive-complexity findings by design, and this
round takes them, since the functions had grown past the point where a flat walk reads better than named parts - and the
split brings the host's segment rendering to the shape the Node twin already has. The envelope codec's cast was
Eric's edit; msgpack ships no type information, so without the cast the basedpyright gate fails
(Unknown | None is not bytes), and the one-line note keeps both his edit and the gate - restoring the cast is the
alternative. Left by design: the memory store's async methods without an await (the store protocol is async; the
Redis store awaits). IDE noise: the requirements inspection on boto3, redis and httpx2 (two extras and the MCP
SDK's own dependency), dictionary typos, British spellings. The Node pack's round is opened in lockstep.

🤖 Generated with Claude Code
Co-Authored-By: Claude Fable 5.1 noreply@anthropic.com

…ube and IDE round, no behaviour change

Seven functions above the threshold of 15 are split along their natural seams: the host's
_ttl, _deliver, _handler_event and _classify_segment; the OTLP decoder's _response_field,
_partial_success_block and _partial_success_field; the span mapper's _start_unix_nano,
_span_status and _span_attributes; the ISO-8601 parser's _date_time_fields and
_fraction_nanos; the LLM helper's _tool and _check_turn_shape. Every check keeps its order
and its message, so the shared vector files pass unchanged. Also the IDE nits: the exporter's
session bound through a narrowed local, the MCP binding's unknown keys built as strings and
its shutdown warning naming the error, a docstring word, and the envelope codec's cast
replaced by a one-line checker note (Eric's edit, kept). CHANGELOG Unreleased Changed 7;
lightweight session log.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@acn-ericlaw
acn-ericlaw merged commit 2f21bb4 into main Nov 16, 2026
5 checks passed
@acn-ericlaw
acn-ericlaw deleted the chore/complexity-round-2026-11-16 branch November 16, 2026 08:52
acn-ericlaw added a commit that referenced this pull request Nov 16, 2026
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
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