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(golangci-lint): ignore typecheck error #100

Merged
merged 1 commit into from
Mar 17, 2024
Merged
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
18 changes: 17 additions & 1 deletion internal/linters/go/golangci_lint/golangci_lint.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package golangci_lint

import (
"fmt"
"strings"

"github.com/qiniu/reviewbot/internal/linters"
"github.com/qiniu/x/xlog"
)
Expand All @@ -17,5 +20,18 @@ func golangciLintHandler(log *xlog.Logger, a linters.Agent) error {
a.LinterConfig.Args = append([]string{}, "run")
}

return linters.GeneralHandler(log, a, linters.GeneralParse)
return linters.GeneralHandler(log, a, golangciLintParse)
}

func golangciLintParse(log *xlog.Logger, output []byte) (map[string][]linters.LinterOutput, error) {
var lineParse = func(line string) (*linters.LinterOutput, error) {
if strings.HasSuffix(line, "(typecheck)") {
// refer: https://github.com/qiniu/reviewbot/issues/82#issuecomment-2002340788
return nil, fmt.Errorf("skip golangci-lint typecheck error: %s", line)
}

return linters.GeneralLineParser(line)
}

return linters.Parse(log, output, lineParse)
}
Loading