package main import "fmt" func init() { register(Check{ Seq: 140, ID: "14", Title: "No raw SQL outside sqlc/Bob", Run: func(ctx *ScanContext, rep *Reporter) { // Check 14: No raw SQL outside sqlc/Bob fmt.Println("=== Check 14: No raw SQL outside sqlc/Bob ===") var rawSQLViolations []rawSQLViolation for _, target := range ctx.backendTargets { for _, v := range checkRawSQL(target.root) { v.file = prefixDisplayPath(target.display, v.file) rawSQLViolations = append(rawSQLViolations, v) } } for _, target := range ctx.pluginTargets { for _, v := range checkRawSQL(target.root) { v.file = prefixDisplayPath(target.display, v.file) rawSQLViolations = append(rawSQLViolations, v) } } if len(rawSQLViolations) > 0 { fmt.Printf(" FAIL: %d raw SQL statement(s) found outside sqlc/Bob:\n", len(rawSQLViolations)) for _, v := range rawSQLViolations { fmt.Printf(" %s:%d %s\n", v.file, v.line, v.snippet) } printRawSQLHelp() rep.Fail() } else { fmt.Println(" OK: No raw SQL outside sqlc/Bob") printPerTargetOKLines(pluginTargetLabels(ctx.pluginTargets)) } fmt.Println() }, }) }