Skip to content

Commit

Permalink
fix: keep only typecheck issues (#4640)
Browse files Browse the repository at this point in the history
  • Loading branch information
ldez committed Apr 14, 2024
1 parent 40d4872 commit 44c070a
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
12 changes: 8 additions & 4 deletions pkg/result/processors/invalid_issue.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,20 @@ func (InvalidIssue) Name() string {
}

func (p InvalidIssue) Process(issues []result.Issue) ([]result.Issue, error) {
tcIssues := filterIssues(issues, func(issue *result.Issue) bool {
return issue.FromLinter == "typecheck"
})

if len(tcIssues) > 0 {
return tcIssues, nil
}

return filterIssuesErr(issues, p.shouldPassIssue)
}

func (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)

Expand Down
15 changes: 15 additions & 0 deletions pkg/result/processors/invalid_issue_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,21 @@ func TestInvalidIssue_Process(t *testing.T) {
{FromLinter: "typecheck"},
},
},
{
desc: "keep only typecheck issues if any exist",
issues: []result.Issue{
{FromLinter: "typecheck"},
{
FromLinter: "example",
Pos: token.Position{
Filename: "test.go",
},
},
},
expected: []result.Issue{
{FromLinter: "typecheck"},
},
},
{
desc: "Go file",
issues: []result.Issue{
Expand Down

0 comments on commit 44c070a

Please sign in to comment.