| id | 224 |
|---|---|
| title | Split internal/lint along question boundaries |
| status | ✅ |
| summary | internal/lint answers too many questions. Move gitignore, limits, and PI into sibling packages each named for their question. parsecache and runcache stay in lint due to a circular-import constraint. |
| model | |
| depends-on |
internal/lint violates SRP. The package has no doc comment, but its twelve non-test source files mix one coherent model with three standalone utilities.
The core parsed-file model (stays in
lint — these are facets of one subject,
a parsed Markdown file):
File/Diagnostic/Rangevalue types (file.go,diagnostic.go).- Code-block AST helpers (
codeblocks.go). - Front-matter extraction
(
frontmatter.go). - Parse cache (
parsecache.go). - Run cache (
runcache.go). - Prose-range projection
(
proserange.go). - Workspace file discovery — Markdown
detection and glob expansion that pick
the files to parse (
files.go). Stays: it feeds the parsed-file model and does not depend on the three utilities below.
The standalone utilities (extracted by this plan — each answers its own question, unrelated to the parsed-file model):
- Gitignore-pattern matching
(
gitignore.go). - Byte-limit guards (
limits.go). - Processing-instruction parsing
(
pi.go,pi_parser.go).
The audit noted this in May 2026. Three more files have been added since. No plan existed.
The Go architecture doc requires each package to answer one question. A package doc comment that joins two unrelated responsibilities with "and" wants to be two packages; listing the facets of a single subject is fine.
- Move
gitignore.goto a new packageinternal/gitignore. Update all callers. The package doc: "gitignore matches a path against .gitignore patterns." - Move
limits.goto a new packageinternal/bytelimit. Update callers. The package doc: "bytelimit guards against oversized inputs." - Move
pi.goandpi_parser.goto a new packageinternal/piparser. Update callers. The package doc: "piparser extracts processing instructions from Markdown." - Assess
parsecache.goandruncache.go:lint.Fileembeds*RunCache(internal/lint/file.go:136), so movingruncache.gotointernal/runcachecreates a circular import and is not viable. Keep both inlintand add a comment in internal/lint/file.go explaining the coupling. Document the decision here. - Add
internal/lint/doc.gowith a package doc whose subject is one noun — the parsed Markdown file — e.g. "lint models a parsed Markdown file: its source, AST, front matter, diagnostics, caches, and prose ranges." (The "and" here lists facets of one subject, not separate responsibilities.) - Verify
internal/lintnow answers one question: "what is a parsed Markdown file?" - Run
go build ./...andgo test ./....
-
internal/gitignoreexists with a focused package doc. -
internal/bytelimitexists with a focused package doc. -
internal/piparserexists with a focused package doc. -
internal/lint/doc.goexists with a package doc whose subject is a single noun — the parsed Markdown file — not a conjunction of unrelated responsibilities. -
go build ./...clean. -
go test ./...passes. -
go tool golangci-lint runclean.