| id | 2606071930 |
|---|---|
| title | Consolidate duplicated table-parse helpers in tablereadability |
| status | ✅ |
| summary | Move tablereadability's private findTables/tryParseTable into tablefmt so the two rules share one copy. |
| model | sonnet |
| depends-on |
Remove duplicated findTables and tryParseTable from
internal/rules/tablereadability/rule.go by sharing the
boundary-detection logic already in
internal/rules/tablefmt.
Both tablereadability and tablefmt carry private copies
of findTables and tryParseTable. The copies diverged on
the perf pass (1ee98e7). Future perf or correctness fixes
risk being applied to one copy and missed in the other.
The two table types differ. tablefmt.table stores
cells []string for formatting. tablereadability.tableRow
stores cells [][]byte for zero-alloc counting. A clean
consolidation exports boundary detection separately from
cell parsing. Or it accepts distinct table types with
a shared scanner.
Severity: tax (DRY violation; copies diverge on every perf pass).
- Export a table-boundary scanner from
tablefmt— a helper that returns start/end indices of each table block without parsing cells. - Update
tablereadabilityto call the exported scanner and parse cells itself from the detected line ranges. - Add or update unit tests in both packages.
- Verify
TestRulesDoNotImportEachOtherstill passes. - Verify no regression:
go test ./....
- Table-boundary scanning exists in one package only.
-
tablereadabilitydoes not duplicate scanning logic. -
TestRulesDoNotImportEachOtherpasses. - All tests pass:
go test ./... -
go tool golangci-lint runreports no issues