1
0
mirror of https://github.com/mgechev/revive.git synced 2025-05-15 21:56:38 +02:00
revive/formatter/plain.go

29 lines
673 B
Go
Raw Normal View History

package formatter
import (
"fmt"
2024-12-08 11:08:54 +01:00
"strings"
"github.com/mgechev/revive/lint"
)
// Plain is an implementation of the Formatter interface
// which formats the errors to JSON.
type Plain struct {
Metadata lint.FormatterMetadata
}
// Name returns the name of the formatter
2022-04-10 11:55:13 +02:00
func (*Plain) Name() string {
return "plain"
}
// Format formats the failures gotten from the lint.
2022-04-10 11:55:13 +02:00
func (*Plain) Format(failures <-chan lint.Failure, _ lint.Config) (string, error) {
2024-12-08 11:08:54 +01:00
var sb strings.Builder
for failure := range failures {
2024-12-08 11:08:54 +01:00
sb.WriteString(fmt.Sprintf("%v: %s %s\n", failure.Position.Start, failure.Failure, ruleDescriptionURL(failure.RuleName)))
}
2024-12-08 11:08:54 +01:00
return sb.String(), nil
}