check-safety/check_protoownership.go
Alex Dunmow c4d01de82c feat: concise output + diff-scoped any check
Reporter is now a collector: checks declare a verdict (OK/Skip/Warn/Fail/
Fatal) plus findings, and a single central render() prints output. Default
output is silent on pass/skip — only FAIL/WARN/ERR checks print, followed by
one tally line, so a clean run is two lines. --verbose restores full per-check
output. All ~30 checks were converted to this API; orphaned guidance/label
helpers (printPerTargetOKLines, per-check *Help blocks, colors_format.go) were
removed.

The any-usage check (2e) now defaults to only the unstaged working-tree diff
(changed lines), via a new per-repo git-diff index in changedlines.go; --all-any
restores the full scan. Not-a-git-repo / no-diff warns on nothing.

Golden fixtures regenerated; integration tests updated to the new format; added
unit tests for the diff index.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-04 01:16:56 +08:00

38 lines
1.3 KiB
Go

package main
func init() {
register(Check{
Seq: 21,
ID: "2b",
Title: "Plugin proto ownership",
Run: func(ctx *ScanContext, rep *Reporter) {
var protoOwnershipViolations []protoOwnershipViolation
for _, target := range ctx.backendTargets {
if !isPluginModuleRoot(target.root) {
continue
}
violations, err := checkPluginProtoOwnership(target.root, target.displayOrRoot())
if err != nil {
rep.Fatal("failed to check proto ownership for %s: %v", target.displayOrRoot(), err)
}
protoOwnershipViolations = append(protoOwnershipViolations, violations...)
}
for _, target := range ctx.pluginTargets {
violations, err := checkPluginProtoOwnership(target.root, target.display)
if err != nil {
rep.Fatal("failed to check proto ownership for %s: %v", target.display, err)
}
protoOwnershipViolations = append(protoOwnershipViolations, violations...)
}
if len(protoOwnershipViolations) > 0 {
rep.Fail("%d plugin proto ownership violation(s)", len(protoOwnershipViolations))
for _, v := range protoOwnershipViolations {
rep.Findingf("%s [%s] local proto missing; matching proto exists in %s", v.root, v.namespace, v.coreProto)
}
} else {
rep.OK("Plugin proto ownership is clean")
}
},
})
}