Skip to content

fix: expose linters.All() registry, document sprintfbool, add bidirectional doc-sync guard#47007

Merged
pelikhan merged 3 commits into
mainfrom
copilot/fix-doc-sync-guards
Jul 21, 2026
Merged

fix: expose linters.All() registry, document sprintfbool, add bidirectional doc-sync guard#47007
pelikhan merged 3 commits into
mainfrom
copilot/fix-doc-sync-guards

Conversation

Copilot AI commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

sprintfbool was registered in cmd/linters/main.go as 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 main package, making it unimportable. Every doc surface was maintained by hand and drifted independently with no cross-check possible.

Changes

  • pkg/linters/registry.go — new All() []*analysis.Analyzer function: the single importable source of truth for all 55 analyzers.

  • cmd/linters/main.go — collapsed to two lines:

    func main() {
        multichecker.Main(linters.All()...)
    }

    Adding a linter now requires one edit in registry.go; main.go never needs to change again.

  • pkg/linters/spec_test.go — added TestRegistryMatchesDocumentation, a bidirectional guard:

    • every entry in linters.All() must appear in documentedAnalyzers()
    • every entry in documentedAnalyzers() must appear in linters.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 header 54 → 55, added sprintfbool bullet.

  • pkg/linters/README.md — added sprintfbool to overview bullets, Subpackages table, Usage Examples, and Dependencies.

…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
Copilot AI requested a review from pelikhan July 21, 2026 07:36
@pelikhan
pelikhan marked this pull request as ready for review July 21, 2026 07:36
Copilot AI review requested due to automatic review settings July 21, 2026 07:36
@pelikhan
pelikhan merged commit 0f4d77f into main Jul 21, 2026
17 checks passed
@pelikhan
pelikhan deleted the copilot/fix-doc-sync-guards branch July 21, 2026 07:37

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 sprintfbool and 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 thread pkg/linters/spec_test.go
Comment on lines +258 to +260
documentedNames := make(map[string]struct{}, len(documented))
for _, d := range documented {
documentedNames[d.analyzer.Name] = struct{}{}
Comment thread pkg/linters/registry.go
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 {
@github-actions

Copy link
Copy Markdown
Contributor

🎉 This pull request is included in a new release.

Release: v0.82.15

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

3 participants