count empty files in the number of parsed files in text output

This commit is contained in:
Yann Hamon 2020-10-18 13:52:40 +02:00
parent 54d899f8f6
commit 51732e6a21
5 changed files with 24 additions and 5 deletions

View file

@ -41,7 +41,7 @@ func JSON(w io.Writer, withSummary bool, verbose bool) Output {
func (o *jsono) Write(filename, kind, name, version string, err error, skipped bool) error {
msg, st := "", ""
s := status(err, skipped)
s := status(kind, name, err, skipped)
switch s {
case VALID:
@ -58,9 +58,10 @@ func (o *jsono) Write(filename, kind, name, version string, err error, skipped b
case SKIPPED:
st = "SKIPPED"
o.nSkipped++
case EMPTY:
}
if o.verbose || (s != VALID && s != SKIPPED) {
if o.verbose || (s != VALID && s != SKIPPED && s != EMPTY ) {
o.results = append(o.results, result{Filename: filename, Kind: kind, Name: name, Version: version, Status: st, Msg: msg})
}

View file

@ -10,6 +10,7 @@ const (
INVALID
ERROR
SKIPPED
EMPTY
)
type Output interface {
@ -17,7 +18,11 @@ type Output interface {
Flush() error
}
func status(err error, skipped bool) int {
func status(kind, name string, err error, skipped bool) int {
if name == "" && kind == "" && err == nil && skipped == false {
return EMPTY
}
if skipped {
return SKIPPED
}

View file

@ -36,7 +36,7 @@ func (o *text) Write(filename, kind, name, version string, reserr error, skipped
var err error
o.files[filename] = true
switch status(reserr, skipped) {
switch status(kind, name, reserr, skipped) {
case VALID:
if o.verbose {
_, err = fmt.Fprintf(o.w, "%s - %s %s is valid\n", filename, kind, name)
@ -57,6 +57,7 @@ func (o *text) Write(filename, kind, name, version string, reserr error, skipped
_, err = fmt.Fprintf(o.w, "%s - %s %s skipped\n", filename, name, kind)
}
o.nSkipped++
case EMPTY:
}
return err