refactor(rename): export NormalizedLabel/RefDefBracketBytes, remove lsp duplicates - #690
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files
☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
…sp copies Export `normalizedLabel` → `NormalizedLabel` and `refDefBracketBytes` → `RefDefBracketBytes` from `internal/rename`. Delete the identical private copies from `internal/lsp/rename.go` and update all lsp call sites to use the shared exports. Adds dedicated tests for both exported helpers. Also adds plan files for the two remaining test-debt items from the 2026-06-24 architecture audit (lsp/rename.go helpers and export.go helpers). Closes plan/2606240214_arch-fix-rename-dedup.md Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PQQBtYXUNuyr4HmoGGk26T
…el API duplicate - Add nil guard after RefDefBracketBytes(row) in refDefEditsInBody: the function returns nil for non-ref-def rows and was indexed unconditionally, matching the pattern the LSP caller already follows. - Delete NormalizeLabel(string) from heading.go: its sole caller (cmd/mdsmith/rename.go) now calls NormalizedLabel([]byte(oldName)) directly, eliminating a second confusably-named exported symbol from the package. - Remove TestRefDefBracketBytes_Exported from rename_test.go: it duplicated TestRefDefBracketBytes in helpers_test.go with no new coverage. - Remove TestNormalizeLabel from heading_test.go (function deleted). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PQQBtYXUNuyr4HmoGGk26T
…x gofmt - LinkRef now normalizes oldLabel internally at the function entry so callers can pass raw label text or a pre-normalized form; both produce identical results (normalization is idempotent). - Remove the nil guard on RefDefBracketBytes that was added in the prior commit: the regex in validRefDefMatches and RefDefBracketBytes are semantically equivalent on splitLines-processed rows, so the guard is dead code. Removing it avoids silent partial renames if the guard ever fired (continue would have dropped the def-edit while use-edits were still included). - CLI: remove pre-normalization of oldName before calling LinkRef; LinkRef normalizes internally now. - lsp/rename.go: remove two double blank lines left by the function deletion in the prior commit (gofmt violation). - Update plan/2606240212 to remove stale references to the two lsp helpers that were deleted in this PR branch. - Red/Green TDD: TestLinkRef_NormalizesOldLabel added first (failing), then the oldLabel = NormalizedLabel(...) line added to make it pass.
PLAN.md catalog was out of date (MDS019): regenerated to include the three new plan files added in the rename-dedup work. plan/2606240212: paragraph at line 26 exceeded the readability index (MDS023). Rewrote to use shorter sentences without changing meaning.
jeduden
force-pushed
the
claude/youthful-knuth-hsz74x
branch
from
June 24, 2026 05:26
6f43065 to
30fdf68
Compare
Owner
Author
|
🟢 Merge Queue — picked up This PR is in the queue and will be batched with other Next: No action needed — you'll get another comment when CI starts on the batch. View merge queue run. |
Owner
Author
|
🔵 Merge Queue — CI running Merged into batch branch Next: No action needed — you'll be notified when CI completes. |
Owner
Author
|
✅ Merge Queue — merged This PR landed on Next: Done — nothing more to do here. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
NormalizedLabelandRefDefBracketBytesfrominternal/rename, deleting the identical private copies ininternal/lsp/rename.go(flagged by the 2026-06-24 arch audit)LinkRefnow normalizesoldLabelinternally so callers may pass raw or pre-normalized text; the CLI no longer needs to callNormalizedLabelbefore callingLinkRefNormalizeLabel(string) stringwrapper fromheading.go(confusable withNormalizedLabel([]byte) string, differing only by trailingd)ValidRefDefBodyLines/contentBlockLinesreturn types frommap[int]booltomap[int]struct{}consistent with the repo'smap[K]bool → map[K]struct{}migrationlsp/rename.goleft by the function deletionTest plan
go test ./...is green (3 commits, each passing)TestLinkRef_NormalizesOldLabelcovers the new internal normalization (red → green TDD)TestNormalizedLabelcoversNormalizedLabel([]byte)directlyTestRefDefBracketBytes/TestRefDefBracketBytesEdgeCasescover the exported helpergofmt -l internal/lsp/rename.goproduces no outputCode review rounds
3 sequential
/code-review xhighrounds completed. All confirmed findings addressed:RefDefBracketBytes(added then removed as dead code after analysis); duplicate test removed; confusableNormalizeLabelAPI deletedLinkRefnormalization internalized; plan/2606240212 stale entries removed🤖 Generated with Claude Code
Generated by Claude Code