mirror of
https://github.com/mgechev/revive.git
synced 2024-11-28 08:49:11 +02:00
Update formatters
This commit is contained in:
parent
5c6de19f89
commit
25cfe541d2
@ -37,6 +37,7 @@ func (f *CLIFormatter) Format(failures <-chan linter.Failure) (string, error) {
|
||||
var result [][]string
|
||||
var totalErrors = 0
|
||||
var total = 0
|
||||
|
||||
for f := range failures {
|
||||
result = append(result, formatFailure(f))
|
||||
total++
|
||||
|
@ -14,9 +14,13 @@ type JSONFormatter struct {
|
||||
|
||||
// Format formats the failures gotten from the linter.
|
||||
func (f *JSONFormatter) Format(failures <-chan linter.Failure) (string, error) {
|
||||
result, error := json.Marshal(failures)
|
||||
if error != nil {
|
||||
return "", error
|
||||
var slice []linter.Failure
|
||||
for failure := range failures {
|
||||
slice = append(slice, failure)
|
||||
}
|
||||
return string(result), nil
|
||||
result, err := json.Marshal(slice)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return string(result), err
|
||||
}
|
||||
|
@ -4,4 +4,4 @@ import:
|
||||
- package: github.com/mattn/go-runewidth
|
||||
version: ~0.0.2
|
||||
- package: github.com/fatih/color
|
||||
version: ~1.5.0
|
||||
version: ~1.5.0
|
@ -9,5 +9,5 @@ type FormatterMetadata struct {
|
||||
|
||||
// Formatter defines an interface for failure formatters
|
||||
type Formatter interface {
|
||||
Format(<-chan Failure) string
|
||||
Format(<-chan Failure, <-chan string, int) string
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ type Failure struct {
|
||||
Category string
|
||||
Type FailureType
|
||||
Position FailurePosition
|
||||
Node ast.Node
|
||||
Node ast.Node `json:"-"`
|
||||
Confidence float64
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user