-
-
Notifications
You must be signed in to change notification settings - Fork 8
/
failure.go
58 lines (48 loc) · 1007 Bytes
/
failure.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package main
import (
"fmt"
"go/token"
"strings"
)
type failure struct {
Position struct {
Start token.Position
End token.Position
}
Failure string
Severity string
}
func (f *failure) Format() string {
var sb strings.Builder
if f.Severity == "warning" {
sb.WriteString("::warning ")
} else {
sb.WriteString("::error ")
}
fmt.Fprintf(&sb, "file=%s,line=%d,endLine=%d,col=%d,endColumn=%d::%s",
f.Position.Start.Filename, f.Position.Start.Line,
f.Position.End.Line, f.Position.Start.Column,
f.Position.End.Column, f.Failure)
return sb.String()
}
type statistics struct {
Total, Warnings, Errors int
}
func (s statistics) String() string {
return fmt.Sprintf("%d failures (%d warnings, %d errors)",
s.Total, s.Warnings, s.Errors)
}
func (s statistics) ToMarkdownTable() string {
return fmt.Sprintf(`
### Revive Summary
| Category | Count |
|:---------|------:|
| ⚠️ Warnings | %d |
| ❌ Errors | %d |
| Total | %d |
`,
s.Warnings,
s.Errors,
s.Total,
)
}