mirror of
https://github.com/mgechev/revive.git
synced 2025-03-21 21:17:06 +02:00
Add severity to json formatter (#33)
* Add severity to json formatter * Rename struct 'JSONObject'
This commit is contained in:
parent
1cab2ac566
commit
1e0238d20a
@ -17,11 +17,20 @@ func (f *JSON) Name() string {
|
||||
return "json"
|
||||
}
|
||||
|
||||
// jsonObject defines a JSON object of an failure
|
||||
type jsonObject struct {
|
||||
Severity lint.Severity
|
||||
lint.Failure `json:",inline"`
|
||||
}
|
||||
|
||||
// Format formats the failures gotten from the lint.
|
||||
func (f *JSON) Format(failures <-chan lint.Failure, config lint.RulesConfig) (string, error) {
|
||||
var slice []lint.Failure
|
||||
var slice []jsonObject
|
||||
for failure := range failures {
|
||||
slice = append(slice, failure)
|
||||
obj := jsonObject{}
|
||||
obj.Severity = severity(config, failure)
|
||||
obj.Failure = failure
|
||||
slice = append(slice, obj)
|
||||
}
|
||||
result, err := json.Marshal(slice)
|
||||
if err != nil {
|
||||
|
Loading…
x
Reference in New Issue
Block a user