golangci-lint/pkg/result/processors/invalid_issue.go
dependabot[bot] afd670b92f
build(deps): bump github.com/kkHAIKE/contextcheck from 1.1.4 to 1.1.5 (#4564)
Co-authored-by: Fernandez Ludovic <ldez@users.noreply.github.com>
2024-03-23 04:51:07 +01:00

53 lines
1.1 KiB
Go

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
}