Skip to content

Commit

Permalink
fix: don't hide typecheck errors inside diff processor (#4674)
Browse files Browse the repository at this point in the history
  • Loading branch information
ldez committed Apr 24, 2024
1 parent 8bea8e7 commit c1f9f54
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pkg/result/processors/autogenerated_exclude.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func (p *AutogeneratedExclude) Process(issues []result.Issue) ([]result.Issue, e
func (*AutogeneratedExclude) Finish() {}

func (p *AutogeneratedExclude) shouldPassIssue(issue *result.Issue) (bool, error) {
if issue.FromLinter == "typecheck" {
if issue.FromLinter == typeCheckName {
// don't hide typechecking errors in generated files: users expect to see why the project isn't compiling
return true, nil
}
Expand Down
5 changes: 5 additions & 0 deletions pkg/result/processors/diff.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ func (p Diff) Process(issues []result.Issue) ([]result.Issue, error) {
}

return transformIssues(issues, func(issue *result.Issue) *result.Issue {
if issue.FromLinter == typeCheckName {
// Never hide typechecking errors.
return issue
}

hunkPos, isNew := c.IsNewIssue(issue)
if !isNew {
return nil
Expand Down
2 changes: 1 addition & 1 deletion pkg/result/processors/invalid_issue.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ 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"
return issue.FromLinter == typeCheckName
})

if len(tcIssues) > 0 {
Expand Down
2 changes: 2 additions & 0 deletions pkg/result/processors/processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import (
"github.com/golangci/golangci-lint/pkg/result"
)

const typeCheckName = "typecheck"

type Processor interface {
Process(issues []result.Issue) ([]result.Issue, error)
Name() string
Expand Down

0 comments on commit c1f9f54

Please sign in to comment.