fix(audit): show actual active analyzers in status --json output

When no explicit analyzer filter was configured, status --json reported
an empty analyzers array. Now ResolvePolicy backfills the full list of
built-in analyzer IDs so the JSON output reflects what actually runs.

Add Registry.IDs() helper with deduplication (markdownLinkAnalyzer and
staticAnalyzer share the "static" ID).
This commit is contained in:
Willie
2026-03-06 02:15:36 +08:00
parent 4b09d2ee3d
commit bcf31d851a
2 changed files with 18 additions and 0 deletions
+13
View File
@@ -57,6 +57,19 @@ func (r *Registry) BundleAnalyzers() []Analyzer {
return r.byScope(ScopeBundle)
}
// IDs returns the unique IDs of all analyzers in the registry.
func (r *Registry) IDs() []string {
seen := make(map[string]bool, len(r.analyzers))
var ids []string
for _, a := range r.analyzers {
if !seen[a.ID()] {
seen[a.ID()] = true
ids = append(ids, a.ID())
}
}
return ids
}
// Has returns true if an analyzer with the given ID is in the registry.
func (r *Registry) Has(id string) bool {
for _, a := range r.analyzers {
+5
View File
@@ -66,6 +66,11 @@ func ResolvePolicy(in PolicyInputs) Policy {
if len(analyzers) == 0 {
analyzers = in.ConfigAnalyzers
}
// When no explicit filter is set, report all built-in analyzers
// so callers (e.g. status --json) see the actual active set.
if len(analyzers) == 0 {
analyzers = DefaultRegistry().IDs()
}
return Policy{
Profile: profile,