fix(cli): consistent output format, sorted findings, version flag
- Workflow rules now use strict if: evaluation (parse failure → skip rule, not match); fixes premature matching that blocked later rules and injected wrong variables into the context - Single = accepted as alias for == in rules:if: expressions - File/Line preserved through extends: resolution (lost during YAML encode/decode round-trip in the resolver) - Findings sorted by (File, Line, Rule) so same-file issues group together - All warnings use ruff-style path: [warning] message format (includes, extends chains, workflow non-start) - Add --version / -v flag; version shown at top of every --help output - Build injects version via ldflags using git describe Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
package linter
|
||||
|
||||
import (
|
||||
"cmp"
|
||||
"fmt"
|
||||
"slices"
|
||||
"strings"
|
||||
|
||||
"git.k3nny.fr/glint/internal/model"
|
||||
@@ -48,7 +50,8 @@ func (f Finding) String() string {
|
||||
return fmt.Sprintf("%s%s%s %s", loc, rule, sev, msg)
|
||||
}
|
||||
|
||||
// Lint runs all rules against p and returns findings sorted by job name.
|
||||
// Lint runs all rules against p and returns findings sorted by (File, Line, Rule).
|
||||
// Findings with no File (pipeline-level) sort before file-scoped ones.
|
||||
func Lint(p *model.Pipeline) []Finding {
|
||||
var findings []Finding
|
||||
findings = append(findings, checkStages(p)...)
|
||||
@@ -57,6 +60,15 @@ func Lint(p *model.Pipeline) []Finding {
|
||||
findings = append(findings, checkNeeds(p)...)
|
||||
findings = append(findings, checkDependencies(p)...)
|
||||
findings = append(findings, checkVariableRefs(p)...)
|
||||
slices.SortStableFunc(findings, func(a, b Finding) int {
|
||||
if c := cmp.Compare(a.File, b.File); c != 0 {
|
||||
return c
|
||||
}
|
||||
if c := cmp.Compare(a.Line, b.Line); c != 0 {
|
||||
return c
|
||||
}
|
||||
return cmp.Compare(a.Rule, b.Rule)
|
||||
})
|
||||
return findings
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user