Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: keep only typecheck issues #4640

Merged
merged 2 commits into from
Apr 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading