Skip to content

Commit 44c070a

Browse files
authored
fix: keep only typecheck issues (#4640)
1 parent 40d4872 commit 44c070a

File tree

2 files changed

+23
-4
lines changed

2 files changed

+23
-4
lines changed

pkg/result/processors/invalid_issue.go

+8-4
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,20 @@ func (InvalidIssue) Name() string {
2222
}
2323

2424
func (p InvalidIssue) Process(issues []result.Issue) ([]result.Issue, error) {
25+
tcIssues := filterIssues(issues, func(issue *result.Issue) bool {
26+
return issue.FromLinter == "typecheck"
27+
})
28+
29+
if len(tcIssues) > 0 {
30+
return tcIssues, nil
31+
}
32+
2533
return filterIssuesErr(issues, p.shouldPassIssue)
2634
}
2735

2836
func (InvalidIssue) Finish() {}
2937

3038
func (p InvalidIssue) shouldPassIssue(issue *result.Issue) (bool, error) {
31-
if issue.FromLinter == "typecheck" {
32-
return true, nil
33-
}
34-
3539
if issue.FilePath() == "" {
3640
p.log.Warnf("no file path for the issue: probably a bug inside the linter %q: %#v", issue.FromLinter, issue)
3741

pkg/result/processors/invalid_issue_test.go

+15
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,21 @@ func TestInvalidIssue_Process(t *testing.T) {
3131
{FromLinter: "typecheck"},
3232
},
3333
},
34+
{
35+
desc: "keep only typecheck issues if any exist",
36+
issues: []result.Issue{
37+
{FromLinter: "typecheck"},
38+
{
39+
FromLinter: "example",
40+
Pos: token.Position{
41+
Filename: "test.go",
42+
},
43+
},
44+
},
45+
expected: []result.Issue{
46+
{FromLinter: "typecheck"},
47+
},
48+
},
3449
{
3550
desc: "Go file",
3651
issues: []result.Issue{

0 commit comments

Comments
 (0)