package main import "strings" func init() { register(Check{ Seq: 30, ID: "3", Title: "Go code compiles and passes go fix, golangci-lint --fix, go vet, and strict lint", Run: func(ctx *ScanContext, rep *Reporter) { goLintRoots := make([]string, 0, len(ctx.pluginTargets)) for _, target := range ctx.pluginTargets { goLintRoots = append(goLintRoots, target.root) } backendLintRoots := make([]string, 0, len(ctx.backendTargets)) for _, target := range ctx.backendTargets { backendLintRoots = append(backendLintRoots, target.root) } completedGoTargets, skippedGoTargets, goLintFailures, goLintErr := runStrictGoLint(ctx.repoRoot, backendLintRoots, goLintRoots) if goLintErr != nil { rep.Fatal("failed to run Go lint pipeline: %v", goLintErr) } for _, skipped := range skippedGoTargets { rep.Skip("%s", skipped) } if len(goLintFailures) > 0 { rep.Fail("%d Go module(s) failed the Go lint pipeline", len(goLintFailures)) for _, failure := range goLintFailures { rep.Findingf("[%s]", failure.target) if failure.output != "" { for line := range strings.SplitSeq(failure.output, "\n") { rep.Findingf(" %s", line) } } } } else if len(completedGoTargets) > 0 { rep.OK("Go lint pipeline clean for %d module(s)", len(completedGoTargets)) } else { rep.Skip("no Go modules found") } }, }) }