diff --git a/cmd/core-lint/main.go b/cmd/core-lint/main.go index 03d5867..c09c915 100644 --- a/cmd/core-lint/main.go +++ b/cmd/core-lint/main.go @@ -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(), ) } diff --git a/pkg/lint/adapter.go b/pkg/lint/adapter.go index fcbbc66..221b395 100644 --- a/pkg/lint/adapter.go +++ b/pkg/lint/adapter.go @@ -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 diff --git a/pkg/lint/report.go b/pkg/lint/report.go index 90616fb..41a9cc3 100644 --- a/pkg/lint/report.go +++ b/pkg/lint/report.go @@ -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) } } diff --git a/pkg/lint/scanner.go b/pkg/lint/scanner.go index 203e088..8d4dac8 100644 --- a/pkg/lint/scanner.go +++ b/pkg/lint/scanner.go @@ -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.