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>
56 lines
1.9 KiB
Go
56 lines
1.9 KiB
Go
package main
|
|
|
|
import "sort"
|
|
|
|
func init() {
|
|
register(Check{
|
|
Seq: 110,
|
|
ID: "11",
|
|
Title: "No placeholder code; only shipped features",
|
|
Run: func(ctx *ScanContext, rep *Reporter) {
|
|
comingSoonViolations := []comingSoonViolation{}
|
|
placeholderRoots := make([]todoScanRoot, 0, len(ctx.backendTargets)+len(ctx.frontendTargets)+len(ctx.pluginTargets))
|
|
for _, target := range ctx.backendTargets {
|
|
placeholderRoots = append(placeholderRoots, todoScanRoot{
|
|
root: target.root,
|
|
displayPrefix: target.display,
|
|
})
|
|
}
|
|
for _, target := range ctx.frontendTargets {
|
|
for _, v := range checkComingSoon(target.dir) {
|
|
v.file = prefixDisplayPath(target.label, v.file)
|
|
comingSoonViolations = append(comingSoonViolations, v)
|
|
}
|
|
placeholderRoots = append(placeholderRoots, todoScanRoot{
|
|
root: target.dir,
|
|
displayPrefix: target.label,
|
|
})
|
|
}
|
|
for _, target := range ctx.pluginTargets {
|
|
placeholderRoots = append(placeholderRoots, todoScanRoot{
|
|
root: target.root,
|
|
displayPrefix: target.display,
|
|
})
|
|
}
|
|
placeholderViolations := checkPlaceholderLanguage(placeholderRoots)
|
|
allPlaceholderViolations := append(comingSoonViolations, placeholderViolations...)
|
|
|
|
sort.Slice(allPlaceholderViolations, func(i, j int) bool {
|
|
if allPlaceholderViolations[i].file == allPlaceholderViolations[j].file {
|
|
return allPlaceholderViolations[i].line < allPlaceholderViolations[j].line
|
|
}
|
|
return allPlaceholderViolations[i].file < allPlaceholderViolations[j].file
|
|
})
|
|
|
|
if len(allPlaceholderViolations) > 0 {
|
|
rep.Fail("%d placeholder reference(s) found — ship the feature now", len(allPlaceholderViolations))
|
|
for _, v := range allPlaceholderViolations {
|
|
rep.Findingf("%s:%d %s", v.file, v.line, v.snippet)
|
|
}
|
|
} else {
|
|
rep.OK("No placeholder code found")
|
|
}
|
|
},
|
|
})
|
|
}
|