/
invalid_issue.go
52 lines (37 loc) · 1.05 KB
/
invalid_issue.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
package processors
import (
"path/filepath"
"github.com/golangci/golangci-lint/pkg/logutils"
"github.com/golangci/golangci-lint/pkg/result"
)
var _ Processor = InvalidIssue{}
type InvalidIssue struct {
log logutils.Log
}
func NewInvalidIssue(log logutils.Log) *InvalidIssue {
return &InvalidIssue{log: log}
}
func (p InvalidIssue) Process(issues []result.Issue) ([]result.Issue, error) {
return filterIssuesErr(issues, p.shouldPassIssue)
}
func (p InvalidIssue) Name() string {
return "invalid_issue"
}
func (p InvalidIssue) Finish() {}
func (p InvalidIssue) shouldPassIssue(issue *result.Issue) (bool, error) {
if issue.FromLinter == "typecheck" {
return true, nil
}
if issue.FilePath() == "" {
p.log.Warnf("no file path for the issue: probably a bug inside the linter %q: %#v", issue.FromLinter, issue)
return false, nil
}
if filepath.Base(issue.FilePath()) == "go.mod" {
return true, nil
}
if !isGoFile(issue.FilePath()) {
p.log.Infof("issue related to file %s is skipped", issue.FilePath())
return false, nil
}
return true, nil
}