fix core-lint CLI missing-tool output
This commit is contained in:
parent
2181582ade
commit
7dedeece42
1 changed files with 27 additions and 2 deletions
|
|
@ -9,10 +9,10 @@ import (
|
|||
"sort"
|
||||
"strings"
|
||||
|
||||
"forge.lthn.ai/core/cli/pkg/cli"
|
||||
coreerr "forge.lthn.ai/core/go-log"
|
||||
cataloglint "dappco.re/go/core/lint"
|
||||
lintpkg "dappco.re/go/core/lint/pkg/lint"
|
||||
"forge.lthn.ai/core/cli/pkg/cli"
|
||||
coreerr "forge.lthn.ai/core/go-log"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
|
@ -91,6 +91,7 @@ func newRunCommand(commandName string, summary string, defaults lintpkg.RunInput
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
report = stripMissingToolFindings(report)
|
||||
|
||||
if err := writeReport(command.OutOrStdout(), input.Output, report); err != nil {
|
||||
return err
|
||||
|
|
@ -423,6 +424,30 @@ func writeIndentedJSON(writer io.Writer, value any) error {
|
|||
return encoder.Encode(value)
|
||||
}
|
||||
|
||||
func stripMissingToolFindings(report lintpkg.Report) lintpkg.Report {
|
||||
if len(report.Findings) == 0 {
|
||||
return report
|
||||
}
|
||||
passed := report.Summary.Passed
|
||||
|
||||
filtered := make([]lintpkg.Finding, 0, len(report.Findings))
|
||||
for _, finding := range report.Findings {
|
||||
if finding.Code == "missing-tool" {
|
||||
continue
|
||||
}
|
||||
filtered = append(filtered, finding)
|
||||
}
|
||||
|
||||
if len(filtered) == len(report.Findings) {
|
||||
return report
|
||||
}
|
||||
|
||||
report.Findings = filtered
|
||||
report.Summary = lintpkg.Summarise(filtered)
|
||||
report.Summary.Passed = passed
|
||||
return report
|
||||
}
|
||||
|
||||
func writeCatalogSummary(writer io.Writer, findings []lintpkg.Finding) {
|
||||
summary := lintpkg.Summarise(findings)
|
||||
fmt.Fprintf(writer, "\n%d finding(s)", summary.Total)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue