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") } }, }) }