1
0
mirror of https://github.com/mgechev/revive.git synced 2025-09-16 09:06:22 +02:00

New formatter: unix (#65)

This commit is contained in:
Sylvain Kerkour
2018-09-17 20:57:56 +02:00
committed by Minko Gechev
parent 2387290dcf
commit 2e16582cbc
2 changed files with 28 additions and 0 deletions

View File

@@ -72,6 +72,7 @@ var allFormatters = []lint.Formatter{
&formatter.JSON{},
&formatter.NDJSON{},
&formatter.Default{},
&formatter.Unix{},
&formatter.Checkstyle{},
}

27
formatter/unix.go Normal file
View File

@@ -0,0 +1,27 @@
package formatter
import (
"fmt"
"github.com/mgechev/revive/lint"
)
// Unix is an implementation of the Formatter interface
// which formats the errors to a simple line based error format
// main.go:24:9: [errorf] should replace errors.New(fmt.Sprintf(...)) with fmt.Errorf(...)
type Unix struct {
Metadata lint.FormatterMetadata
}
// Name returns the name of the formatter
func (f *Unix) Name() string {
return "unix"
}
// Format formats the failures gotten from the lint.
func (f *Unix) Format(failures <-chan lint.Failure, config lint.RulesConfig) (string, error) {
for failure := range failures {
fmt.Printf("%v: [%s] %s\n", failure.Position.Start, failure.RuleName, failure.Failure)
}
return "", nil
}