8c3605ed52
Replace the per-line fmt.Println loop with writeTextFindings() in cmd/glint/output.go. The new renderer: - Aligns all findings into four space-separated columns: location, rule ID, severity, message — widths computed from the full finding set so all lines are flush - Colors severity words when stdout is a TTY and NO_COLOR is not set: red+bold for "error", orange+bold for "warning"; location dimmed; rule ID bold - Formats location as file:line:col when column is known, file:line otherwise, falling back to just file To populate column numbers, add Column int to model.Job (set from keyNode.Column in the YAML parser) and Finding.Column (set during the checkJob source-location attachment pass and in the ten cross-job check sites that explicitly set Line: job.Line). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
56 lines
1.4 KiB
Go
56 lines
1.4 KiB
Go
package linter
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"git.k3nny.fr/glint/internal/model"
|
|
)
|
|
|
|
func checkDependencies(p *model.Pipeline, skipped map[string]bool) []Finding {
|
|
stageIndex := make(map[string]int, len(p.Stages))
|
|
for i, s := range p.Stages {
|
|
stageIndex[s] = i
|
|
}
|
|
|
|
var findings []Finding
|
|
for name, job := range p.Jobs {
|
|
if skipped[name] {
|
|
continue
|
|
}
|
|
if len(job.Dependencies) == 0 {
|
|
continue
|
|
}
|
|
jobStageIdx, jobHasStage := stageIndex[job.Stage]
|
|
for _, dep := range job.Dependencies {
|
|
depJob, exists := p.Jobs[dep]
|
|
if !exists {
|
|
findings = append(findings, Finding{
|
|
Severity: Error,
|
|
Rule: RuleUnknownDependency,
|
|
Job: name,
|
|
File: job.File,
|
|
Line: job.Line,
|
|
Column: job.Column,
|
|
Message: fmt.Sprintf("'dependencies' references unknown job %q", dep),
|
|
})
|
|
continue
|
|
}
|
|
if len(p.Stages) > 0 && jobHasStage && depJob.Stage != "" {
|
|
depIdx, depHasStage := stageIndex[depJob.Stage]
|
|
if depHasStage && depIdx >= jobStageIdx {
|
|
findings = append(findings, Finding{
|
|
Severity: Error,
|
|
Rule: RuleDependencyStage,
|
|
Job: name,
|
|
File: job.File,
|
|
Line: job.Line,
|
|
Column: job.Column,
|
|
Message: fmt.Sprintf("'dependencies' job %q must be in an earlier stage (in %q, current job is in %q)", dep, depJob.Stage, job.Stage),
|
|
})
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return findings
|
|
}
|