fix: expose linters.All() registry, document sprintfbool, add bidirectional doc-sync guard#47007
Merged
Conversation
5 tasks
…nal completeness test Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix doc-sync guards to check analyzer registry
fix: expose linters.All() registry, document sprintfbool, add bidirectional doc-sync guard
Jul 21, 2026
pelikhan
marked this pull request as ready for review
July 21, 2026 07:36
Contributor
There was a problem hiding this comment.
Pull request overview
Centralizes the Go analyzer registry and adds safeguards against documentation drift.
Changes:
- Introduces
linters.All()as the canonical analyzer registry. - Updates the CLI to consume the shared registry.
- Documents
sprintfbooland expands registry/documentation tests.
Show a summary per file
| File | Description |
|---|---|
pkg/linters/registry.go |
Adds the shared analyzer registry. |
cmd/linters/main.go |
Uses linters.All() with multichecker. |
pkg/linters/spec_test.go |
Expands analyzer coverage and adds synchronization checks. |
pkg/linters/doc.go |
Updates analyzer count and documents sprintfbool. |
pkg/linters/README.md |
Adds sprintfbool across documentation sections. |
Review details
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 5/6 changed files
- Comments generated: 2
- Review effort level: Medium
Comment on lines
+258
to
+260
| documentedNames := make(map[string]struct{}, len(documented)) | ||
| for _, d := range documented { | ||
| documentedNames[d.analyzer.Name] = struct{}{} |
Comment on lines
+63
to
+68
| // All returns all registered custom analysis linters. | ||
| // | ||
| // This is the canonical, importable source of truth for the full set of active | ||
| // analyzers. Use it to drive multichecker.Main, test assertions, and | ||
| // doc-completeness checks so that every consumer stays in sync automatically. | ||
| func All() []*analysis.Analyzer { |
This was referenced Jul 21, 2026
Contributor
|
🎉 This pull request is included in a new release. Release: |
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.
sprintfboolwas registered incmd/linters/main.goas the 55th analyzer but absent from all documentation surfaces (doc.go,README.md,spec_test.go). This is the fifth recurrence of the same drift pattern — each prior fix was purely mechanical with no structural guard to prevent recurrence.Root cause
The analyzer list lived in a
mainpackage, making it unimportable. Every doc surface was maintained by hand and drifted independently with no cross-check possible.Changes
pkg/linters/registry.go— newAll() []*analysis.Analyzerfunction: the single importable source of truth for all 55 analyzers.cmd/linters/main.go— collapsed to two lines:Adding a linter now requires one edit in
registry.go;main.gonever needs to change again.pkg/linters/spec_test.go— addedTestRegistryMatchesDocumentation, a bidirectional guard:linters.All()must appear indocumentedAnalyzers()documentedAnalyzers()must appear inlinters.All()Also promoted 9 analyzers that were already in the README/doc.go but missing from the hand-list (
appendoneelement,bytescomparestring,httprespbodyclose,httpstatuscode,osgetenvlibrary,sprintfbool,sprintfint,timenowsub,trimleftright), bringing the documented count from 46 → 55.pkg/linters/doc.go— bumped header54 → 55, addedsprintfboolbullet.pkg/linters/README.md— addedsprintfboolto overview bullets, Subpackages table, Usage Examples, and Dependencies.