mirror of
https://github.com/mgechev/revive.git
synced 2024-11-30 08:57:07 +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 result [][]string
|
||||||
var totalErrors = 0
|
var totalErrors = 0
|
||||||
var total = 0
|
var total = 0
|
||||||
|
|
||||||
for f := range failures {
|
for f := range failures {
|
||||||
result = append(result, formatFailure(f))
|
result = append(result, formatFailure(f))
|
||||||
total++
|
total++
|
||||||
|
@ -14,9 +14,13 @@ type JSONFormatter struct {
|
|||||||
|
|
||||||
// Format formats the failures gotten from the linter.
|
// Format formats the failures gotten from the linter.
|
||||||
func (f *JSONFormatter) Format(failures <-chan linter.Failure) (string, error) {
|
func (f *JSONFormatter) Format(failures <-chan linter.Failure) (string, error) {
|
||||||
result, error := json.Marshal(failures)
|
var slice []linter.Failure
|
||||||
if error != nil {
|
for failure := range failures {
|
||||||
return "", error
|
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
|
- package: github.com/mattn/go-runewidth
|
||||||
version: ~0.0.2
|
version: ~0.0.2
|
||||||
- package: github.com/fatih/color
|
- 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
|
// Formatter defines an interface for failure formatters
|
||||||
type Formatter interface {
|
type Formatter interface {
|
||||||
Format(<-chan Failure) string
|
Format(<-chan Failure, <-chan string, int) string
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,7 @@ type Failure struct {
|
|||||||
Category string
|
Category string
|
||||||
Type FailureType
|
Type FailureType
|
||||||
Position FailurePosition
|
Position FailurePosition
|
||||||
Node ast.Node
|
Node ast.Node `json:"-"`
|
||||||
Confidence float64
|
Confidence float64
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user