Skip to content

[Code Quality] Add cross-check test that linter registry count matches doc.go and README #47013

Description

@github-actions

Description

The custom-linter registry (55 analyzers in cmd/linters/main.go) has drifted from pkg/linters/doc.go (54) and pkg/linters/README.md (54) repeatedly. The existing tests only compare surfaces against each other — never against the authoritative registry — so they always pass even when drift occurs. Root cause: multichecker.Main(...) is in package main and is unimportable, so nothing can enumerate it.

Suggested Changes

  1. Add a test in pkg/linters/spec_test.go (or a new registry_test.go) that parses cmd/linters/main.go via go/ast or a simple regex to count/enumerate registered analyzers.
  2. Compare the parsed count/list against doc.go bullet count and README.md table rows.
  3. Fail with a descriptive message listing the missing entries when any surface is out of sync.
  4. Update doc.go and README.md to add sprintfbool (the 55th linter currently missing).

Files Affected

  • pkg/linters/spec_test.go (or new pkg/linters/registry_sync_test.go)
  • pkg/linters/doc.go — add sprintfbool entry
  • pkg/linters/README.md — add sprintfbool row

Success Criteria

  • New test fails when a new analyzer is added to cmd/linters/main.go without updating docs
  • sprintfbool is documented in both doc.go and README.md
  • All existing tests pass

Source

Extracted from Sergo Report: Registry Catch-up + Doc-Sync Root-Cause - 2026-07-21 #46979

See also existing tracking issue #46977.

Priority

Medium — doc drift keeps recurring; a test guard will prevent future regressions

🔍 Task mining by Discussion Task Miner - Code Quality Improvement Agent · 39.1 AIC · ⌖ 5.29 AIC · ⊞ 7K ·

  • expires on Jul 21, 2026, 11:40 PM UTC-08:00

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions