refactor(device): consolidate SCPI error-code extraction into ScpiResponseClassifier (part of #345) - #357
Conversation
…ponseClassifier (part of #345) DaqifiStreamingDevice.TryParseScpiErrorCode independently re-derived the **ERROR/ERROR prefix + delimiter-trim logic that ScpiResponseClassifier already owns for line *detection*, risking drift in the accepted delimiter set. The extraction now lives next to the matchers as ScpiResponseClassifier.TryExtractErrorCode, with a single-sourced TokenDelimiters set; the device's two call sites delegate to it and the private duplicate is removed. Behavior-preserving. Addresses acceptance-criterion 3 of #345 (the last of the three batch items). - 12 new TryExtractErrorCode tests (all delimiter variants, no-comma, positive code, whitespace/CRLF; non-numeric/non-error -> false + code 0). Full suite 1647 pass / 0 fail (net9+net10). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
/agentic_review |
PR Summary by QodoConsolidate SCPI error-code extraction into ScpiResponseClassifier
AI Description
Diagram
High-Level Assessment
Files changed (3)
|
Code Review by Qodo
Context used 1.
|
…(single delimiter source) Addresses Qodo review on #357: TokenDelimiters was documented as the single source of truth but only TryExtractErrorCode used it — the prefix matchers still hard-coded ':'/' '/'\t'. Both matchers now consult a shared IsTokenDelimiter(char) helper, so a future delimiter change can't drift detection from extraction. Behavior-preserving (in the strict matcher ':' is handled before the check, so !IsTokenDelimiter(next) reduces exactly to the prior "not space/tab" test). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
Fixed in the latest commit. Added |
|
/agentic_review |
|
Code review by qodo was updated up to the latest commit cc8fc91 |
…ly, matchers use IsTokenDelimiter) Addresses Qodo review on #357: the comment claimed TryExtractErrorCode consults IsTokenDelimiter, but it trims with the TokenDelimiters array directly; only the matchers use IsTokenDelimiter. Reworded to describe each accurately — both still draw from the one array. Doc-only, no behavior change. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
Fixed — reworded the Note: the earlier CI "build" failure was the unrelated flaky |
|
/agentic_review |
|
Code review by qodo was updated up to the latest commit 55f468e |
Summary
DaqifiStreamingDevice.TryParseScpiErrorCodeindependently re-derived the**ERROR/ERRORprefix + delimiter-trim logic thatScpiResponseClassifieralready owns for line detection — the exact drift risk #345 item 3 calls out. Extraction now lives next to the matchers asScpiResponseClassifier.TryExtractErrorCode, so detection and extraction share one file (and oneTokenDelimitersset); the device's two call sites delegate to it and the private duplicate is deleted. Behavior-preserving.Changes
ScpiResponseClassifier.TryExtractErrorCode(line, out code)(new, internal) — the moved extraction logic, plus a single-sourcedprivate static readonly char[] TokenDelimiters = { ':', ' ', '\t' }documenting the accepted delimiters in one place.DaqifiStreamingDevice— both call sites (the SCPI-error classification and the-200reboot-detection path) now callScpiResponseClassifier.TryExtractErrorCode; the privateTryParseScpiErrorCodeis removed.Testing
dotnet test— 1647 passed / 0 failed / 2 skipped (net9.0 + net10.0); existing error-parse behavior preserved through the delegating call sites.TryExtractErrorCodeunit tests: all:/space/tab delimiter variants across**ERROR/ERROR, no-trailing-comma, positive code, leading/trailing whitespace + CRLF; and non-numeric / non-error / filename lines →falsewithcode == 0.Scope note
Closes acceptance-criterion 3 of #345 — the last of the three batch items (item 1 = PWM skip #356, item 2 =
SetFriendlyNameAsync#355). #345 is fully addressed once all three merge; not adding acloseskeyword here so the issue isn't closed before #355/#356 land.Not merging — for review.
🤖 Generated with Claude Code