-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathgolangci-lint.go
55 lines (50 loc) · 1.37 KB
/
golangci-lint.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
package main
import "strings"
type Issue struct {
FromLinter string `json:"FromLinter"`
Text string `json:"Text"`
Severity string `json:"Severity"`
SourceLines []string `json:"SourceLines"`
Replacement interface{} `json:"Replacement"`
Pos struct {
Filename string `json:"Filename"`
Offset int `json:"Offset"`
Line int `json:"Line"`
Column int `json:"Column"`
} `json:"Pos"`
ExpectNoLint bool `json:"ExpectNoLint"`
ExpectedNoLintLinter string `json:"ExpectedNoLintLinter"`
LineRange struct {
From int `json:"From"`
To int `json:"To"`
} `json:"LineRange,omitempty"`
}
func (i Issue) DiagSeverity() DiagnosticSeverity {
if i.Severity == "" {
// TODO: How to get default-severity from .golangci.yml, if available?
i.Severity = defaultSeverity
}
switch strings.ToLower(i.Severity) {
case "err", "error":
return DSError
case "warn", "warning":
return DSWarning
case "info", "information":
return DSInformation
case "hint":
return DSHint
default:
return DSWarning
}
}
//nolint:unused,deadcode
type GolangCILintResult struct {
Issues []Issue `json:"Issues"`
Report struct {
Linters []struct {
Name string `json:"Name"`
Enabled bool `json:"Enabled"`
EnabledByDefault bool `json:"EnabledByDefault,omitempty"`
} `json:"Linters"`
} `json:"Report"`
}