refactor(lint): align naming with AX principles

Co-Authored-By: Virgil <virgil@lethean.io>
This commit is contained in:
Virgil 2026-04-01 12:48:12 +00:00
parent 10f89a83f2
commit 85dc5f75d0
4 changed files with 24 additions and 24 deletions

View file

@ -41,7 +41,7 @@ func addRFCCommands(parent *cli.Command) {
newRunCommand("js", "Run JS/TS linters", lintpkg.RunInput{Lang: "js"}),
newRunCommand("python", "Run Python linters", lintpkg.RunInput{Lang: "python"}),
newRunCommand("security", "Run security linters", lintpkg.RunInput{Category: "security"}),
newRunCommand("compliance", "Run compliance linters", lintpkg.RunInput{Category: "compliance", SBOM: true}),
newRunCommand("compliance", "Run compliance linters", lintpkg.RunInput{Category: "compliance"}),
newHookCommand(),
)
}

View file

@ -280,7 +280,7 @@ func (CatalogAdapter) Entitlement() string { return "" }
func (CatalogAdapter) RequiresEntitlement() bool { return false }
func (CatalogAdapter) MatchesLanguage(languages []string) bool {
return len(languages) == 0 || slicesContains(languages, "go")
return len(languages) == 0 || containsString(languages, "go")
}
func (CatalogAdapter) Category() string { return "correctness" }
@ -846,7 +846,7 @@ func firstVersionLine(output string) string {
return ""
}
func slicesContains(values []string, target string) bool {
func containsString(values []string, target string) bool {
for _, value := range values {
if value == target {
return true

View file

@ -21,27 +21,27 @@ type Summary struct {
//
// summary := lint.Summarise(findings)
func Summarise(findings []Finding) Summary {
s := Summary{
summary := Summary{
Total: len(findings),
BySeverity: make(map[string]int),
}
for _, f := range findings {
severity := strings.TrimSpace(f.Severity)
for _, finding := range findings {
severity := strings.TrimSpace(finding.Severity)
if severity == "" {
severity = "warning"
}
s.BySeverity[severity]++
summary.BySeverity[severity]++
switch severity {
case "error":
s.Errors++
summary.Errors++
case "info":
s.Info++
summary.Info++
default:
s.Warnings++
summary.Warnings++
}
}
s.Passed = s.Errors == 0
return s
summary.Passed = summary.Errors == 0
return summary
}
// WriteJSON writes findings as a pretty-printed JSON array.
@ -76,16 +76,16 @@ func WriteJSONL(w io.Writer, findings []Finding) error {
//
// lint.WriteText(os.Stdout, findings)
func WriteText(w io.Writer, findings []Finding) {
for _, f := range findings {
message := f.Message
for _, finding := range findings {
message := finding.Message
if message == "" {
message = f.Title
message = finding.Title
}
code := f.Code
code := finding.Code
if code == "" {
code = f.RuleID
code = finding.RuleID
}
fmt.Fprintf(w, "%s:%d [%s] %s (%s)\n", f.File, f.Line, f.Severity, message, code)
fmt.Fprintf(w, "%s:%d [%s] %s (%s)\n", finding.File, finding.Line, finding.Severity, message, code)
}
}

View file

@ -79,12 +79,12 @@ type Scanner struct {
// NewScanner creates a Scanner with the given rules and default directory exclusions.
func NewScanner(rules []Rule) (*Scanner, error) {
m, err := NewMatcher(rules)
matcher, err := NewMatcher(rules)
if err != nil {
return nil, err
}
return &Scanner{
matcher: m,
matcher: matcher,
rules: rules,
}, nil
}
@ -131,7 +131,7 @@ func (s *Scanner) ScanDir(root string) ([]Finding, error) {
content := []byte(raw)
// Build a matcher scoped to this file's language.
m, err := NewMatcher(langRules)
matcher, err := NewMatcher(langRules)
if err != nil {
return err
}
@ -142,7 +142,7 @@ func (s *Scanner) ScanDir(root string) ([]Finding, error) {
relPath = path
}
found := m.Match(relPath, content)
found := matcher.Match(relPath, content)
findings = append(findings, found...)
return nil
})
@ -172,12 +172,12 @@ func (s *Scanner) ScanFile(path string) ([]Finding, error) {
return nil, nil
}
m, err := NewMatcher(langRules)
matcher, err := NewMatcher(langRules)
if err != nil {
return nil, err
}
return m.Match(path, content), nil
return matcher.Match(path, content), nil
}
// filterRulesByLanguage returns rules that include the given language.