Skip to content

feat: err113 analyzer name #4567

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

Merged
merged 2 commits into from
Mar 28, 2024
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions .golangci.next.reference.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2525,6 +2525,7 @@ linters:
- dupl
- dupword
- durationcheck
- err113
- errcheck
- errchkjson
- errname
Expand All @@ -2548,7 +2549,6 @@ linters:
- gocyclo
- godot
- godox
- goerr113
- gofmt
- gofumpt
- goheader
Expand Down Expand Up @@ -2638,6 +2638,7 @@ linters:
- dupl
- dupword
- durationcheck
- err113
- errcheck
- errchkjson
- errname
Expand All @@ -2661,7 +2662,6 @@ linters:
- gocyclo
- godot
- godox
- goerr113
- gofmt
- gofumpt
- goheader
Expand Down
2 changes: 1 addition & 1 deletion jsonschema/golangci.next.jsonschema.json
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@
"gocyclo",
"godot",
"godox",
"goerr113",
"err113",
"gofmt",
"gofumpt",
"goheader",
Expand Down
8 changes: 5 additions & 3 deletions pkg/golinters/goerr113.go → pkg/golinters/err113.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@ import (
"github.com/golangci/golangci-lint/pkg/goanalysis"
)

func NewGoerr113() *goanalysis.Linter {
func NewErr113() *goanalysis.Linter {
a := err113.NewAnalyzer()

return goanalysis.NewLinter(
"goerr113",
a.Name,
"Go linter to check the errors handling expressions",
[]*analysis.Analyzer{err113.NewAnalyzer()},
[]*analysis.Analyzer{a},
nil,
).WithLoadMode(goanalysis.LoadModeTypesInfo)
}
3 changes: 2 additions & 1 deletion pkg/lint/lintersdb/builder_linter.go
Original file line number Diff line number Diff line change
Expand Up @@ -252,10 +252,11 @@ func (b LinterBuilder) Build(cfg *config.Config) ([]*linter.Config, error) {
WithPresets(linter.PresetStyle, linter.PresetComment).
WithURL("https://github.com/matoous/godox"),

linter.NewConfig(golinters.NewGoerr113()).
linter.NewConfig(golinters.NewErr113()).
WithSince("v1.26.0").
WithPresets(linter.PresetStyle, linter.PresetError).
WithLoadForGoAnalysis().
WithAlternativeNames("goerr113").
WithURL("https://github.com/Djarvur/go-err113"),

linter.NewConfig(golinters.NewGofmt(&cfg.LintersSettings.Gofmt)).
Expand Down
2 changes: 1 addition & 1 deletion pkg/printers/testdata/golden-json.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pkg/printers/testdata/in-report-data.json
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@
"Name": "godox"
},
{
"Name": "goerr113"
"Name": "err113"
},
{
"Name": "gofmt",
Expand Down
21 changes: 21 additions & 0 deletions test/testdata/err113.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//golangcitest:args -Eerr113
package testdata

import "os"

func SimpleEqual(e1, e2 error) bool {
return e1 == e2 // want `do not compare errors directly "e1 == e2", use "errors.Is\(e1, e2\)" instead`
}

func SimpleNotEqual(e1, e2 error) bool {
return e1 != e2 // want `do not compare errors directly "e1 != e2", use "!errors.Is\(e1, e2\)" instead`
}

func CheckGoerr13Import(e error) bool {
f, err := os.Create("f.txt")
if err != nil {
return err == e // want `do not compare errors directly "err == e", use "errors.Is\(err, e\)" instead`
}
f.Close()
return false
}
21 changes: 0 additions & 21 deletions test/testdata/goerr113.go

This file was deleted.