| id | 2606260614 |
|---|---|
| title | arch-fix: add dedicated unit tests for lineclass_scan.go HTML-scanning helpers |
| status | ✅ |
| summary | Nine unexported sub-functions of the type-7 HTML block scanning path in internal/lint/lineclass_scan.go lack dedicated unit tests. This plan adds TestScanHTMLTag, TestScanClosingTag, TestScanOpenTag, TestScanTagName, TestScanAttribute, TestScanAttrValue, TestSkipHTMLWS, TestIsUnquotedStop, and TestEqualFoldASCII. |
| model | sonnet |
Nine unexported HTML-scanning helpers in
internal/lint/lineclass_scan.go lack
dedicated unit tests. Add a dedicated
TestFoo for each one. Closes the 2026-06-26
audit finding.
Audit 2026-06-26 (range: 3d35b77..fe7141b)
flagged nine unexported helpers. All nine
are sub-functions of htmlType7Start:
scanHTMLTag(s []byte) (int, bool)scanClosingTag(s []byte, i int) (int, bool)scanOpenTag(s []byte, i int) (int, bool)scanTagName(s []byte, i int) (int, bool)scanAttribute(s []byte, i int) (int, bool)scanAttrValue(s []byte, i int) (int, bool)skipHTMLWS(s []byte, i int) intisUnquotedStop(b byte) boolequalFoldASCII(a, b []byte) bool
The existing TestHTMLType7Start exercises
these indirectly. The architecture tests doc
§"every function by name" requires a
dedicated test per function.
- Add
TestScanHTMLTagtointernal/lint/lineclass_scan_test.go. Cover the open-tag path, the closing-tag path, and a non-<byte that returns(0, false). - Add
TestScanClosingTag. Cover</tagname>success, missing>, and a name starting with a digit. - Add
TestScanOpenTag. Cover a minimal<img>success,<img />, one attribute, and failure cases (<img src=>, unclosed tag). - Add
TestScanTagName. Cover a valid name, a name starting with a digit (fail), an empty input (fail), and a name terminated by>. - Add
TestScanAttribute. Cover a plain valueless attribute, akey=valuepair, akey="value"pair, and=with no value. - Add
TestScanAttrValue. Cover bare unquoted, single-quoted, and double-quoted values; an unclosed quote; and an empty unquoted value. - Add
TestSkipHTMLWS. Cover spaces, tabs, a mix, and a non-whitespace byte at position 0. - Add
TestIsUnquotedStop. Cover bytes that stop (",',=,>,`, control bytes) and bytes that do not. - Add
TestEqualFoldASCII. Cover same-case match, mixed-case match, different bytes (no match), and different lengths (no match).
- Each of the nine functions has a
dedicated top-level
TestFooininternal/lint/lineclass_scan_test.go. -
go test ./internal/lint/...green. -
go vet ./...clean. - No production code changed; tests only.