1 Star 0 Fork 0

Laomo./golangci-lint

Create your Gitee Account
Explore and code with more than 14 million developers,Free private repositories !:)
Sign up
文件
Clone or Download
errcheck.go 1.17 KB
Copy Edit Raw Blame History
Denis Isaev authored 2018-06-29 03:39 +08:00 . Fix #96: support lll
package golinters
import (
"context"
"fmt"
"github.com/golangci/golangci-lint/pkg/lint/linter"
"github.com/golangci/golangci-lint/pkg/result"
errcheckAPI "github.com/kisielk/errcheck/golangci"
)
type Errcheck struct{}
func (Errcheck) Name() string {
return "errcheck"
}
func (Errcheck) Desc() string {
return "Errcheck is a program for checking for unchecked errors " +
"in go programs. These unchecked errors can be critical bugs in some cases"
}
func (e Errcheck) Run(ctx context.Context, lintCtx *linter.Context) ([]result.Issue, error) {
errCfg := &lintCtx.Settings().Errcheck
issues, err := errcheckAPI.Run(lintCtx.Program, errCfg.CheckAssignToBlank, errCfg.CheckTypeAssertions)
if err != nil {
return nil, err
}
if len(issues) == 0 {
return nil, nil
}
res := make([]result.Issue, 0, len(issues))
for _, i := range issues {
var text string
if i.FuncName != "" {
text = fmt.Sprintf("Error return value of %s is not checked", formatCode(i.FuncName, lintCtx.Cfg))
} else {
text = "Error return value is not checked"
}
res = append(res, result.Issue{
FromLinter: e.Name(),
Text: text,
Pos: i.Pos,
})
}
return res, nil
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/LaomoBK/golangci-lint.git
git@gitee.com:LaomoBK/golangci-lint.git
LaomoBK
golangci-lint
golangci-lint
v1.10.1

Search