github.com/zmap/zlint@v1.1.0/integration/result.go (about) 1 // +build integration 2 3 package integration 4 5 import ( 6 "fmt" 7 8 "github.com/zmap/zlint/lints" 9 ) 10 11 type resultCount struct { 12 FatalCount uint8 `json:",omitempty"` 13 ErrCount uint8 `json:",omitempty"` 14 WarnCount uint8 `json:",omitempty"` 15 NoticeCount uint8 `json:",omitempty"` 16 } 17 18 // TODO(@cpu): Accept a threshold argument so that (for e.g. notices could be 19 // counted as passing) 20 func (r resultCount) fullPass() bool { 21 return r.FatalCount == 0 && r.ErrCount == 0 && r.WarnCount == 0 && r.NoticeCount == 0 22 } 23 24 func (r resultCount) String() string { 25 return fmt.Sprintf("fatals: %-4d errs: %-4d warns: %-4d infos: %-4d", 26 r.FatalCount, r.ErrCount, r.WarnCount, r.NoticeCount) 27 } 28 29 // Inc increases the resultCount count for the given lint status level. 30 func (r *resultCount) Inc(status lints.LintStatus) { 31 switch status { 32 case lints.Notice: 33 r.NoticeCount++ 34 case lints.Warn: 35 r.WarnCount++ 36 case lints.Error: 37 r.ErrCount++ 38 case lints.Fatal: 39 r.FatalCount++ 40 } 41 } 42 43 // certResult combines a Result (overall count of lint results by type) with 44 // a LintSummary (map from lint name to a Notice/Warn/Error/Fatal result) for 45 // a specific cert Fingerprint. 46 type certResult struct { 47 Fingerprint string 48 Result resultCount 49 LintSummary map[string]lints.LintStatus 50 } 51 52 func (cr certResult) String() string { 53 return fmt.Sprintf("%q\t%s", cr.Fingerprint, cr.Result) 54 }