package main import "fmt" func init() { register(Check{ Seq: 24, ID: "2e", Title: "Warn on any usage in Go and TypeScript", Run: func(ctx *ScanContext, rep *Reporter) { // Check 2e: Warn on any usage in Go and TypeScript fmt.Println("=== Check 2e: Warn on any usage in Go and TypeScript ===") var anyWarnings []anyUsageWarning for _, target := range ctx.backendTargets { for _, w := range checkGoAnyUsage(target.root) { w.file = prefixDisplayPath(target.displayOrRoot(), w.file) anyWarnings = append(anyWarnings, w) } } for _, target := range ctx.pluginTargets { for _, w := range checkGoAnyUsage(target.root) { w.file = prefixDisplayPath(target.display, w.file) anyWarnings = append(anyWarnings, w) } } for _, target := range collectESLintDirectiveTargets(ctx.repoRoot, ctx.frontendTargets) { for _, w := range checkTypeScriptAnyUsage(target.dir) { w.file = prefixDisplayPath(target.label, w.file) anyWarnings = append(anyWarnings, w) } } if len(anyWarnings) > 0 { fmt.Printf(" WARN: %d any usage warning(s):\n", len(anyWarnings)) limit := min(len(anyWarnings), maxAnyWarningsPrinted) for _, w := range anyWarnings[:limit] { fmt.Printf(" %s:%d [%s] %s\n", w.file, w.line, w.lang, w.snippet) } if len(anyWarnings) > limit { fmt.Printf(" ... %d additional warning(s) omitted\n", len(anyWarnings)-limit) } fmt.Println("\n Guidance: prefer concrete types, generics, typed maps/structs, or unknown-style narrowing patterns over any.") } else { fmt.Println(" OK: No any usage found in scanned Go or TypeScript sources") } fmt.Println() }, }) }