закрыты известные остатки
- документ самоуправления объявляется ключом governance, а не угадывается по «он один и без ключей оси»: конвенция, потерявшая topic, была от него неотличима и тихо теряла все проверки об отъезде к потребителю - проверка путей канона больше не ловит README.md и READING.md — эти два имени значат что-то и на стороне потребителя - lang.Recognize требует совпадения и слов, и номера версии; директории компонентов сверяются на вложенность, а не только на равенство - у обеих проверок появился --json, а convy sync называет ссылки на темы, которых компонент не взял
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
package check
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"sort"
|
||||
)
|
||||
@@ -104,3 +105,34 @@ func (r *Report) Errors() int {
|
||||
func (r *Report) Warnings() int {
|
||||
return len(r.findings) - r.Errors()
|
||||
}
|
||||
|
||||
// MarshalJSON writes a finding the way a machine reads it: the severity and the
|
||||
// family as words rather than as the numbers they happen to be inside.
|
||||
func (f Finding) MarshalJSON() ([]byte, error) {
|
||||
return json.Marshal(struct {
|
||||
Severity string `json:"severity"`
|
||||
Family string `json:"family"`
|
||||
Path string `json:"path,omitempty"`
|
||||
Line int `json:"line,omitempty"`
|
||||
Message string `json:"message"`
|
||||
}{f.Severity.String(), string(f.Family), f.Path, f.Line, f.Msg})
|
||||
}
|
||||
|
||||
// JSON renders the report for a caller that is not a person. Findings come out
|
||||
// in the order they are printed in, so the two outputs never disagree about
|
||||
// what was found first.
|
||||
func (r *Report) JSON() ([]byte, error) {
|
||||
out := struct {
|
||||
Findings []Finding `json:"findings"`
|
||||
Errors int `json:"errors"`
|
||||
Warnings int `json:"warnings"`
|
||||
}{r.Findings(), r.Errors(), r.Warnings()}
|
||||
if out.Findings == nil {
|
||||
out.Findings = []Finding{}
|
||||
}
|
||||
body, err := json.Marshal(out)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return append(body, '\n'), nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user