Skip to content

Commit 8d25552

Browse files
author
Sergey Vilgelm
committed
use v1.5.0
1 parent b5fbf96 commit 8d25552

File tree

5 files changed

+23
-24
lines changed

5 files changed

+23
-24
lines changed

go.mod

+3-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ require (
3434
github.com/jgautheron/goconst v0.0.0-20201117150253-ccae5bf973f3
3535
github.com/jingyugao/rowserrcheck v0.0.0-20210130005344-c6a0c12dd98d
3636
github.com/jirfag/go-printf-func-name v0.0.0-20191110105641-45db9963cdd3
37-
github.com/kisielk/errcheck v1.5.0-alpha.0.20201210184435-7e1276f76cf6
37+
github.com/kisielk/errcheck v1.5.0
3838
github.com/kulti/thelper v0.4.0
3939
github.com/kunwardeep/paralleltest v1.0.2
4040
github.com/kyoh86/exportloopref v0.1.8
@@ -84,3 +84,5 @@ require (
8484
mvdan.cc/lint v0.0.0-20170908181259-adc824a0674b // indirect
8585
mvdan.cc/unparam v0.0.0-20200501210554-b37ab49443f7
8686
)
87+
88+
replace github.com/kisielk/errcheck => ../errcheck

go.sum

+2-11
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/golinters/errcheck.go

+16-10
Original file line numberDiff line numberDiff line change
@@ -55,25 +55,31 @@ func NewErrcheck() *goanalysis.Linter {
5555
TypesInfo: pass.TypesInfo,
5656
}
5757

58-
errcheckIssues := checker.CheckPackage(pkg)
58+
errcheckIssues := checker.CheckPackage(pkg).Unique()
5959
if len(errcheckIssues.UncheckedErrors) == 0 {
6060
return nil, nil
6161
}
6262

63-
issues := make([]goanalysis.Issue, 0, len(errcheckIssues.UncheckedErrors))
64-
for _, i := range errcheckIssues.UncheckedErrors {
63+
issues := make([]goanalysis.Issue, len(errcheckIssues.UncheckedErrors))
64+
for i, err := range errcheckIssues.UncheckedErrors {
6565
var text string
66-
if i.FuncName != "" {
67-
text = fmt.Sprintf("Error return value of %s is not checked", formatCode(i.FuncName, lintCtx.Cfg))
66+
if err.FuncName != "" {
67+
text = fmt.Sprintf(
68+
"Error return value of %s is not checked",
69+
formatCode(err.SelectorName, lintCtx.Cfg),
70+
)
6871
} else {
6972
text = "Error return value is not checked"
7073
}
7174

72-
issues = append(issues, goanalysis.NewIssue(&result.Issue{
73-
FromLinter: linterName,
74-
Text: text,
75-
Pos: i.Pos,
76-
}, pass))
75+
issues[i] = goanalysis.NewIssue(
76+
&result.Issue{
77+
FromLinter: linterName,
78+
Text: text,
79+
Pos: err.Pos,
80+
},
81+
pass,
82+
)
7783
}
7884

7985
mu.Lock()

test/testdata/errcheck_exclude.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@ func TestErrcheckExclude() []byte {
1313
}
1414

1515
func TestErrcheckNoExclude() []byte {
16-
ret, _ := ioutil.ReadAll(nil) // ERROR "Error return value of `io/ioutil.ReadAll` is not checked"
16+
ret, _ := ioutil.ReadAll(nil) // ERROR "Error return value of `ioutil.ReadAll` is not checked"
1717
return ret
1818
}

test/testdata/errcheck_ignore.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,6 @@ func TestErrcheckIgnoreIoutil() []byte {
2323
}
2424

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

0 commit comments

Comments
 (0)