| id | 2606240214 |
|---|---|
| title | Remove duplicated helpers between lsp/rename.go and rename/rename.go |
| status | ✅ |
| model | sonnet |
| summary | normalizedLabel and refDefBracketBytes are duplicated with identical bodies in two packages. Export them from rename and remove the lsp copies. Flagged by the 2026-06-24 audit. |
Export normalizedLabel and refDefBracketBytes from
internal/rename and delete the copies in
internal/lsp/rename.go.
The 2026-06-24 audit (range: 1599c9f..09f22d3) found that two private helpers are duplicated with identical bodies:
normalizedLabel(b []byte) string— wrapsutil.ToLinkReference(b)refDefBracketBytes(row []byte) []int— parses bracket bounds on a[label]:line
internal/lsp already imports internal/rename.
Hub §"Anti-patterns we have actually hit" flags this
kind of silent copy as maintenance friction.
If either copy is updated, the other diverges without
a compile error.
- In
internal/rename/rename.go, renamenormalizedLabel→NormalizedLabelandrefDefBracketBytes→RefDefBracketBytes. - Update all callers in
internal/rename/to use the exported names. - Add or update tests in
internal/rename/rename_test.gofor both. - In
internal/lsp/rename.go, delete the private copies of both functions. - Replace every call site in
lsp/rename.gowithrename.NormalizedLabelandrename.RefDefBracketBytes. go build ./...passes.go test ./internal/lsp/... ./internal/rename/...passes.
-
internal/lsp/rename.gohas no privatenormalizedLabelorrefDefBracketBytes. -
internal/rename/rename.goexportsNormalizedLabelandRefDefBracketBytes. -
internal/rename/rename_test.gohas dedicated tests for both helpers. -
go test ./...is green. -
mdsmith check .is green.