Skip to content

Commit a7868b3

Browse files
authored
feat: err113 analyzer name (#4567)
1 parent 07ffe48 commit a7868b3

File tree

8 files changed

+33
-30
lines changed

8 files changed

+33
-30
lines changed

.golangci.next.reference.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2525,6 +2525,7 @@ linters:
25252525
- dupl
25262526
- dupword
25272527
- durationcheck
2528+
- err113
25282529
- errcheck
25292530
- errchkjson
25302531
- errname
@@ -2548,7 +2549,6 @@ linters:
25482549
- gocyclo
25492550
- godot
25502551
- godox
2551-
- goerr113
25522552
- gofmt
25532553
- gofumpt
25542554
- goheader
@@ -2638,6 +2638,7 @@ linters:
26382638
- dupl
26392639
- dupword
26402640
- durationcheck
2641+
- err113
26412642
- errcheck
26422643
- errchkjson
26432644
- errname
@@ -2661,7 +2662,6 @@ linters:
26612662
- gocyclo
26622663
- godot
26632664
- godox
2664-
- goerr113
26652665
- gofmt
26662666
- gofumpt
26672667
- goheader

jsonschema/golangci.next.jsonschema.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@
250250
"gocyclo",
251251
"godot",
252252
"godox",
253-
"goerr113",
253+
"err113",
254254
"gofmt",
255255
"gofumpt",
256256
"goheader",

pkg/golinters/goerr113.go renamed to pkg/golinters/err113.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,13 @@ import (
77
"github.com/golangci/golangci-lint/pkg/goanalysis"
88
)
99

10-
func NewGoerr113() *goanalysis.Linter {
10+
func NewErr113() *goanalysis.Linter {
11+
a := err113.NewAnalyzer()
12+
1113
return goanalysis.NewLinter(
12-
"goerr113",
14+
a.Name,
1315
"Go linter to check the errors handling expressions",
14-
[]*analysis.Analyzer{err113.NewAnalyzer()},
16+
[]*analysis.Analyzer{a},
1517
nil,
1618
).WithLoadMode(goanalysis.LoadModeTypesInfo)
1719
}

pkg/lint/lintersdb/builder_linter.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,10 +252,11 @@ func (b LinterBuilder) Build(cfg *config.Config) ([]*linter.Config, error) {
252252
WithPresets(linter.PresetStyle, linter.PresetComment).
253253
WithURL("https://github.com/matoous/godox"),
254254

255-
linter.NewConfig(golinters.NewGoerr113()).
255+
linter.NewConfig(golinters.NewErr113()).
256256
WithSince("v1.26.0").
257257
WithPresets(linter.PresetStyle, linter.PresetError).
258258
WithLoadForGoAnalysis().
259+
WithAlternativeNames("goerr113").
259260
WithURL("https://github.com/Djarvur/go-err113"),
260261

261262
linter.NewConfig(golinters.NewGofmt(&cfg.LintersSettings.Gofmt)).

pkg/printers/testdata/golden-json.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

pkg/printers/testdata/in-report-data.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@
135135
"Name": "godox"
136136
},
137137
{
138-
"Name": "goerr113"
138+
"Name": "err113"
139139
},
140140
{
141141
"Name": "gofmt",

test/testdata/err113.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
//golangcitest:args -Eerr113
2+
package testdata
3+
4+
import "os"
5+
6+
func SimpleEqual(e1, e2 error) bool {
7+
return e1 == e2 // want `do not compare errors directly "e1 == e2", use "errors.Is\(e1, e2\)" instead`
8+
}
9+
10+
func SimpleNotEqual(e1, e2 error) bool {
11+
return e1 != e2 // want `do not compare errors directly "e1 != e2", use "!errors.Is\(e1, e2\)" instead`
12+
}
13+
14+
func CheckGoerr13Import(e error) bool {
15+
f, err := os.Create("f.txt")
16+
if err != nil {
17+
return err == e // want `do not compare errors directly "err == e", use "errors.Is\(err, e\)" instead`
18+
}
19+
f.Close()
20+
return false
21+
}

test/testdata/goerr113.go

Lines changed: 0 additions & 21 deletions
This file was deleted.

0 commit comments

Comments
 (0)