Skip to content

Commit

Permalink
use v1.5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Sergey Vilgelm committed Feb 25, 2021
1 parent b5fbf96 commit 8d25552
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 24 deletions.
4 changes: 3 additions & 1 deletion go.mod
Expand Up @@ -34,7 +34,7 @@ require (
github.com/jgautheron/goconst v0.0.0-20201117150253-ccae5bf973f3
github.com/jingyugao/rowserrcheck v0.0.0-20210130005344-c6a0c12dd98d
github.com/jirfag/go-printf-func-name v0.0.0-20191110105641-45db9963cdd3
github.com/kisielk/errcheck v1.5.0-alpha.0.20201210184435-7e1276f76cf6
github.com/kisielk/errcheck v1.5.0
github.com/kulti/thelper v0.4.0
github.com/kunwardeep/paralleltest v1.0.2
github.com/kyoh86/exportloopref v0.1.8
Expand Down Expand Up @@ -84,3 +84,5 @@ require (
mvdan.cc/lint v0.0.0-20170908181259-adc824a0674b // indirect
mvdan.cc/unparam v0.0.0-20200501210554-b37ab49443f7
)

replace github.com/kisielk/errcheck => ../errcheck
13 changes: 2 additions & 11 deletions go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 16 additions & 10 deletions pkg/golinters/errcheck.go
Expand Up @@ -55,25 +55,31 @@ func NewErrcheck() *goanalysis.Linter {
TypesInfo: pass.TypesInfo,
}

errcheckIssues := checker.CheckPackage(pkg)
errcheckIssues := checker.CheckPackage(pkg).Unique()
if len(errcheckIssues.UncheckedErrors) == 0 {
return nil, nil
}

issues := make([]goanalysis.Issue, 0, len(errcheckIssues.UncheckedErrors))
for _, i := range errcheckIssues.UncheckedErrors {
issues := make([]goanalysis.Issue, len(errcheckIssues.UncheckedErrors))
for i, err := range errcheckIssues.UncheckedErrors {
var text string
if i.FuncName != "" {
text = fmt.Sprintf("Error return value of %s is not checked", formatCode(i.FuncName, lintCtx.Cfg))
if err.FuncName != "" {
text = fmt.Sprintf(
"Error return value of %s is not checked",
formatCode(err.SelectorName, lintCtx.Cfg),
)
} else {
text = "Error return value is not checked"
}

issues = append(issues, goanalysis.NewIssue(&result.Issue{
FromLinter: linterName,
Text: text,
Pos: i.Pos,
}, pass))
issues[i] = goanalysis.NewIssue(
&result.Issue{
FromLinter: linterName,
Text: text,
Pos: err.Pos,
},
pass,
)
}

mu.Lock()
Expand Down
2 changes: 1 addition & 1 deletion test/testdata/errcheck_exclude.go
Expand Up @@ -13,6 +13,6 @@ func TestErrcheckExclude() []byte {
}

func TestErrcheckNoExclude() []byte {
ret, _ := ioutil.ReadAll(nil) // ERROR "Error return value of `io/ioutil.ReadAll` is not checked"
ret, _ := ioutil.ReadAll(nil) // ERROR "Error return value of `ioutil.ReadAll` is not checked"
return ret
}
2 changes: 1 addition & 1 deletion test/testdata/errcheck_ignore.go
Expand Up @@ -23,6 +23,6 @@ func TestErrcheckIgnoreIoutil() []byte {
}

func TestErrcheckNoIgnoreIoutil() []byte {
ret, _ := ioutil.ReadAll(nil) // ERROR "Error return value of `io/ioutil.ReadAll` is not checked"
ret, _ := ioutil.ReadAll(nil) // ERROR "Error return value of `ioutil.ReadAll` is not checked"
return ret
}

0 comments on commit 8d25552

Please sign in to comment.