dev: group linter implementation and integration tests (#4603)

This commit is contained in:
Ludovic Fernandez 2024-04-09 23:34:55 +02:00 committed by GitHub
parent 93d3a38fe4
commit 2c666ed4eb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
597 changed files with 2802 additions and 1367 deletions

1
.gitignore vendored
View File

@ -3,6 +3,7 @@
/*.pdf /*.pdf
/*.pprof /*.pprof
/*.txt /*.txt
/test.lock
/.idea/ /.idea/
/.vscode/ /.vscode/
/dist/ /dist/

View File

@ -163,27 +163,27 @@ issues:
text: "SA1019: c.cfg.Run.ShowStats is deprecated: use Output.ShowStats instead." text: "SA1019: c.cfg.Run.ShowStats is deprecated: use Output.ShowStats instead."
# Deprecated linter options. # Deprecated linter options.
- path: pkg/golinters/errcheck.go - path: pkg/golinters/errcheck/errcheck.go
linters: [staticcheck] linters: [staticcheck]
text: "SA1019: errCfg.Exclude is deprecated: use ExcludeFunctions instead" text: "SA1019: errCfg.Exclude is deprecated: use ExcludeFunctions instead"
- path: pkg/golinters/govet.go - path: pkg/golinters/govet/govet.go
linters: [staticcheck] linters: [staticcheck]
text: "SA1019: cfg.CheckShadowing is deprecated: the linter should be enabled inside Enable." text: "SA1019: cfg.CheckShadowing is deprecated: the linter should be enabled inside Enable."
- path: pkg/golinters/godot.go - path: pkg/golinters/godot/godot.go
linters: [staticcheck] linters: [staticcheck]
text: "SA1019: settings.CheckAll is deprecated: use Scope instead" text: "SA1019: settings.CheckAll is deprecated: use Scope instead"
- path: pkg/golinters/gci.go - path: pkg/golinters/gci/gci.go
linters: [staticcheck] linters: [staticcheck]
text: "SA1019: settings.LocalPrefixes is deprecated: use Sections instead." text: "SA1019: settings.LocalPrefixes is deprecated: use Sections instead."
- path: pkg/golinters/mnd.go - path: pkg/golinters/mnd/mnd.go
linters: [staticcheck] linters: [staticcheck]
text: "SA1019: settings.Settings is deprecated: use root level settings instead." text: "SA1019: settings.Settings is deprecated: use root level settings instead."
- path: pkg/golinters/mnd.go - path: pkg/golinters/mnd/mnd.go
linters: [staticcheck] linters: [staticcheck]
text: "SA1019: config.GoMndSettings is deprecated: use MndSettings." text: "SA1019: config.GoMndSettings is deprecated: use MndSettings."
# Related to `run.go`, it cannot be removed. # Related to `run.go`, it cannot be removed.
- path: pkg/golinters/gofumpt.go - path: pkg/golinters/gofumpt/gofumpt.go
linters: [staticcheck] linters: [staticcheck]
text: "SA1019: settings.LangVersion is deprecated: use the global `run.go` instead." text: "SA1019: settings.LangVersion is deprecated: use the global `run.go` instead."
- path: pkg/golinters/internal/staticcheck_common.go - path: pkg/golinters/internal/staticcheck_common.go
@ -194,7 +194,7 @@ issues:
text: "SA1019: (.+).(GoVersion|LangVersion) is deprecated: use the global `run.go` instead." text: "SA1019: (.+).(GoVersion|LangVersion) is deprecated: use the global `run.go` instead."
# Based on existing code, the modifications should be limited to make maintenance easier. # Based on existing code, the modifications should be limited to make maintenance easier.
- path: pkg/golinters/unused.go - path: pkg/golinters/unused/unused.go
linters: [gocritic] linters: [gocritic]
text: "rangeValCopy: each iteration copies 160 bytes \\(consider pointers or indexing\\)" text: "rangeValCopy: each iteration copies 160 bytes \\(consider pointers or indexing\\)"

View File

@ -33,23 +33,21 @@ test: build
GL_TEST_RUN=1 go test -v -parallel 2 ./... GL_TEST_RUN=1 go test -v -parallel 2 ./...
.PHONY: test .PHONY: test
# ex: T=gofmt.go make test_fix
# the value of `T` is the name of a file from `test/testdata/fix`
test_fix: build
GL_TEST_RUN=1 go test -v ./test -count 1 -run TestFix/$T
.PHONY: test_fix
test_race: build_race test_race: build_race
GL_TEST_RUN=1 ./$(BINARY) run -v --timeout=5m GL_TEST_RUN=1 ./$(BINARY) run -v --timeout=5m
.PHONY: test_race .PHONY: test_race
test_linters: # ex: T=output.go make test_integration
# the value of `T` is the name of a file from `test/testdata`
test_integration:
GL_TEST_RUN=1 go test -v ./test -count 1 -run TestSourcesFromTestdata/$T GL_TEST_RUN=1 go test -v ./test -count 1 -run TestSourcesFromTestdata/$T
.PHONY: test_linters .PHONY: test_integration
test_linters_sub: # ex: T=multiple-issues-fix.go make test_integration_fix
GL_TEST_RUN=1 go test -v ./test -count 1 -run TestSourcesFromTestdataSubDir/$T # the value of `T` is the name of a file from `test/testdata/fix`
.PHONY: test_linters_sub test_integration_fix: build
GL_TEST_RUN=1 go test -v ./test -count 1 -run TestFix/$T
.PHONY: test_integration_fix
# Maintenance # Maintenance

View File

@ -15,19 +15,16 @@ We don't accept non `go/analysis` linters.
After that: After that:
1. Implement functional tests for the linter: 1. Implement functional tests for the linter:
- Add one file into directory [`test/testdata`](https://github.com/golangci/golangci-lint/tree/master/test/testdata). - Add one file into directory `pkg/golinters/{yourlintername}/testdata/`.
- Run the test to ensure that test fails: - Run the test to ensure that test fails.
```bash
T=yourlintername.go make test_linters
```
- Run: - Run:
```bash ```bash
go run ./cmd/golangci-lint/ run --no-config --disable-all --enable=yourlintername ./test/testdata/yourlintername.go go run ./cmd/golangci-lint/ run --no-config --disable-all --enable={yourlintername} ./pkg/golinters/{yourlintername}/testdata/{yourlintername}.go
``` ```
2. Add a new file `pkg/golinters/{yourlintername}.go`. 2. Add a new file `pkg/golinters/{yourlintername}/{yourlintername}.go`.
Look at other linters in this directory. Look at other linters in this directory.
Implement linter integration and check that test passes. Implement linter integration and check that test passes.
3. Add the new struct for the linter (which you've implemented in `pkg/golinters/{yourlintername}.go`) to the 3. Add the new struct for the linter (which you've implemented in `pkg/golinters/{yourlintername}/{yourlintername}.go`) to the
list of all supported linters in [`pkg/lint/lintersdb/builder_linter.go`](https://github.com/golangci/golangci-lint/blob/master/pkg/lint/lintersdb/builder_linter.go) list of all supported linters in [`pkg/lint/lintersdb/builder_linter.go`](https://github.com/golangci/golangci-lint/blob/master/pkg/lint/lintersdb/builder_linter.go)
to the method `LinterBuilder.Build`. to the method `LinterBuilder.Build`.
- Add `WithSince("next_version")`, where `next_version` must be replaced by the next minor version. (ex: v1.2.0 if the current version is v1.1.0) - Add `WithSince("next_version")`, where `next_version` must be replaced by the next minor version. (ex: v1.2.0 if the current version is v1.1.0)

View File

@ -1,4 +1,4 @@
package golinters package asasalint
import ( import (
"github.com/alingse/asasalint" "github.com/alingse/asasalint"
@ -9,7 +9,7 @@ import (
"github.com/golangci/golangci-lint/pkg/golinters/internal" "github.com/golangci/golangci-lint/pkg/golinters/internal"
) )
func NewAsasalint(setting *config.AsasalintSettings) *goanalysis.Linter { func New(setting *config.AsasalintSettings) *goanalysis.Linter {
cfg := asasalint.LinterSetting{} cfg := asasalint.LinterSetting{}
if setting != nil { if setting != nil {
cfg.Exclude = setting.Exclude cfg.Exclude = setting.Exclude

View File

@ -0,0 +1,11 @@
package asasalint
import (
"testing"
"github.com/golangci/golangci-lint/test/testshared/integration"
)
func TestFromTestdata(t *testing.T) {
integration.RunTestdata(t)
}

View File

@ -1,4 +1,4 @@
package golinters package asciicheck
import ( import (
"github.com/tdakkota/asciicheck" "github.com/tdakkota/asciicheck"
@ -7,7 +7,7 @@ import (
"github.com/golangci/golangci-lint/pkg/goanalysis" "github.com/golangci/golangci-lint/pkg/goanalysis"
) )
func NewAsciicheck() *goanalysis.Linter { func New() *goanalysis.Linter {
a := asciicheck.NewAnalyzer() a := asciicheck.NewAnalyzer()
return goanalysis.NewLinter( return goanalysis.NewLinter(

View File

@ -0,0 +1,11 @@
package asciicheck
import (
"testing"
"github.com/golangci/golangci-lint/test/testshared/integration"
)
func TestFromTestdata(t *testing.T) {
integration.RunTestdata(t)
}

View File

@ -1,4 +1,4 @@
package golinters package bidichk
import ( import (
"strings" "strings"
@ -10,7 +10,7 @@ import (
"github.com/golangci/golangci-lint/pkg/goanalysis" "github.com/golangci/golangci-lint/pkg/goanalysis"
) )
func NewBiDiChk(cfg *config.BiDiChkSettings) *goanalysis.Linter { func New(cfg *config.BiDiChkSettings) *goanalysis.Linter {
a := bidichk.NewAnalyzer() a := bidichk.NewAnalyzer()
cfgMap := map[string]map[string]any{} cfgMap := map[string]map[string]any{}

View File

@ -0,0 +1,11 @@
package bidichk
import (
"testing"
"github.com/golangci/golangci-lint/test/testshared/integration"
)
func TestFromTestdata(t *testing.T) {
integration.RunTestdata(t)
}

View File

@ -1,4 +1,4 @@
package golinters package bodyclose
import ( import (
"github.com/timakin/bodyclose/passes/bodyclose" "github.com/timakin/bodyclose/passes/bodyclose"
@ -7,7 +7,7 @@ import (
"github.com/golangci/golangci-lint/pkg/goanalysis" "github.com/golangci/golangci-lint/pkg/goanalysis"
) )
func NewBodyclose() *goanalysis.Linter { func New() *goanalysis.Linter {
a := bodyclose.Analyzer a := bodyclose.Analyzer
return goanalysis.NewLinter( return goanalysis.NewLinter(

View File

@ -0,0 +1,11 @@
package bodyclose
import (
"testing"
"github.com/golangci/golangci-lint/test/testshared/integration"
)
func TestFromTestdata(t *testing.T) {
integration.RunTestdata(t)
}

View File

@ -1,4 +1,4 @@
package golinters package containedctx
import ( import (
"github.com/sivchari/containedctx" "github.com/sivchari/containedctx"
@ -7,7 +7,7 @@ import (
"github.com/golangci/golangci-lint/pkg/goanalysis" "github.com/golangci/golangci-lint/pkg/goanalysis"
) )
func NewContainedCtx() *goanalysis.Linter { func New() *goanalysis.Linter {
a := containedctx.Analyzer a := containedctx.Analyzer
return goanalysis.NewLinter( return goanalysis.NewLinter(

View File

@ -0,0 +1,11 @@
package containedctx
import (
"testing"
"github.com/golangci/golangci-lint/test/testshared/integration"
)
func TestFromTestdata(t *testing.T) {
integration.RunTestdata(t)
}

View File

@ -1,4 +1,4 @@
package golinters package contextcheck
import ( import (
"github.com/kkHAIKE/contextcheck" "github.com/kkHAIKE/contextcheck"
@ -8,7 +8,7 @@ import (
"github.com/golangci/golangci-lint/pkg/lint/linter" "github.com/golangci/golangci-lint/pkg/lint/linter"
) )
func NewContextCheck() *goanalysis.Linter { func New() *goanalysis.Linter {
analyzer := contextcheck.NewAnalyzer(contextcheck.Configuration{}) analyzer := contextcheck.NewAnalyzer(contextcheck.Configuration{})
return goanalysis.NewLinter( return goanalysis.NewLinter(

View File

@ -0,0 +1,11 @@
package contextcheck
import (
"testing"
"github.com/golangci/golangci-lint/test/testshared/integration"
)
func TestFromTestdata(t *testing.T) {
integration.RunTestdata(t)
}

View File

@ -1,4 +1,4 @@
package golinters package copyloopvar
import ( import (
"github.com/karamaru-alpha/copyloopvar" "github.com/karamaru-alpha/copyloopvar"
@ -8,7 +8,7 @@ import (
"github.com/golangci/golangci-lint/pkg/goanalysis" "github.com/golangci/golangci-lint/pkg/goanalysis"
) )
func NewCopyLoopVar(settings *config.CopyLoopVarSettings) *goanalysis.Linter { func New(settings *config.CopyLoopVarSettings) *goanalysis.Linter {
a := copyloopvar.NewAnalyzer() a := copyloopvar.NewAnalyzer()
var cfg map[string]map[string]any var cfg map[string]map[string]any

View File

@ -0,0 +1,11 @@
package copyloopvar
import (
"testing"
"github.com/golangci/golangci-lint/test/testshared/integration"
)
func TestFromTestdata(t *testing.T) {
integration.RunTestdata(t)
}

View File

@ -1,7 +1,7 @@
//go:build go1.22 //go:build go1.22
//golangcitest:args -Ecopyloopvar //golangcitest:args -Ecopyloopvar
//golangcitest:config_path testdata/configs/copyloopvar.yml //golangcitest:config_path testdata/copyloopvar.yml
package testdata package testdata
import "fmt" import "fmt"

View File

@ -1,4 +1,4 @@
package golinters package cyclop
import ( import (
"github.com/bkielbasa/cyclop/pkg/analyzer" "github.com/bkielbasa/cyclop/pkg/analyzer"
@ -8,7 +8,7 @@ import (
"github.com/golangci/golangci-lint/pkg/goanalysis" "github.com/golangci/golangci-lint/pkg/goanalysis"
) )
func NewCyclop(settings *config.Cyclop) *goanalysis.Linter { func New(settings *config.Cyclop) *goanalysis.Linter {
a := analyzer.NewAnalyzer() a := analyzer.NewAnalyzer()
var cfg map[string]map[string]any var cfg map[string]map[string]any

View File

@ -0,0 +1,11 @@
package cyclop
import (
"testing"
"github.com/golangci/golangci-lint/test/testshared/integration"
)
func TestFromTestdata(t *testing.T) {
integration.RunTestdata(t)
}

View File

@ -1,5 +1,5 @@
//golangcitest:args -Ecyclop //golangcitest:args -Ecyclop
//golangcitest:config_path testdata/configs/cyclop.yml //golangcitest:config_path testdata/cyclop.yml
package testdata package testdata
func cyclopComplexFunc(s string) { // want "calculated cyclomatic complexity for function cyclopComplexFunc is 22, max is 15" func cyclopComplexFunc(s string) { // want "calculated cyclomatic complexity for function cyclopComplexFunc is 22, max is 15"

View File

@ -1,4 +1,4 @@
package golinters package decorder
import ( import (
"strings" "strings"
@ -10,7 +10,7 @@ import (
"github.com/golangci/golangci-lint/pkg/goanalysis" "github.com/golangci/golangci-lint/pkg/goanalysis"
) )
func NewDecorder(settings *config.DecorderSettings) *goanalysis.Linter { func New(settings *config.DecorderSettings) *goanalysis.Linter {
a := decorder.Analyzer a := decorder.Analyzer
// disable all rules/checks by default // disable all rules/checks by default

View File

@ -0,0 +1,11 @@
package decorder
import (
"testing"
"github.com/golangci/golangci-lint/test/testshared/integration"
)
func TestFromTestdata(t *testing.T) {
integration.RunTestdata(t)
}

View File

@ -1,5 +1,5 @@
//golangcitest:args -Edecorder //golangcitest:args -Edecorder
//golangcitest:config_path testdata/configs/decorder_custom.yml //golangcitest:config_path testdata/decorder_custom.yml
package testdata package testdata
import "math" import "math"

View File

@ -1,4 +1,4 @@
package golinters package depguard
import ( import (
"github.com/OpenPeeDeeP/depguard/v2" "github.com/OpenPeeDeeP/depguard/v2"
@ -9,7 +9,7 @@ import (
"github.com/golangci/golangci-lint/pkg/lint/linter" "github.com/golangci/golangci-lint/pkg/lint/linter"
) )
func NewDepguard(settings *config.DepGuardSettings) *goanalysis.Linter { func New(settings *config.DepGuardSettings) *goanalysis.Linter {
conf := depguard.LinterSettings{} conf := depguard.LinterSettings{}
if settings != nil { if settings != nil {

View File

@ -0,0 +1,11 @@
package depguard
import (
"testing"
"github.com/golangci/golangci-lint/test/testshared/integration"
)
func TestFromTestdata(t *testing.T) {
integration.RunTestdata(t)
}

View File

@ -1,5 +1,5 @@
//golangcitest:args -Edepguard //golangcitest:args -Edepguard
//golangcitest:config_path testdata/configs/depguard.yml //golangcitest:config_path testdata/depguard.yml
package testdata package testdata
import ( import (

View File

@ -1,5 +1,5 @@
//golangcitest:args -Edepguard //golangcitest:args -Edepguard
//golangcitest:config_path testdata/configs/depguard_additional_guards.yml //golangcitest:config_path testdata/depguard_additional_guards.yml
package testdata package testdata
import ( import (

View File

@ -1,5 +1,5 @@
//golangcitest:args -Edepguard //golangcitest:args -Edepguard
//golangcitest:config_path testdata/configs/depguard_ignore_file_rules.yml //golangcitest:config_path testdata/depguard_ignore_file_rules.yml
//golangcitest:expected_exitcode 0 //golangcitest:expected_exitcode 0
package testdata package testdata

View File

@ -1,4 +1,4 @@
package golinters package dogsled
import ( import (
"fmt" "fmt"
@ -14,14 +14,14 @@ import (
"github.com/golangci/golangci-lint/pkg/result" "github.com/golangci/golangci-lint/pkg/result"
) )
const dogsledName = "dogsled" const name = "dogsled"
func NewDogsled(settings *config.DogsledSettings) *goanalysis.Linter { func New(settings *config.DogsledSettings) *goanalysis.Linter {
var mu sync.Mutex var mu sync.Mutex
var resIssues []goanalysis.Issue var resIssues []goanalysis.Issue
analyzer := &analysis.Analyzer{ analyzer := &analysis.Analyzer{
Name: dogsledName, Name: name,
Doc: goanalysis.TheOnlyanalyzerDoc, Doc: goanalysis.TheOnlyanalyzerDoc,
Run: func(pass *analysis.Pass) (any, error) { Run: func(pass *analysis.Pass) (any, error) {
issues := runDogsled(pass, settings) issues := runDogsled(pass, settings)
@ -39,7 +39,7 @@ func NewDogsled(settings *config.DogsledSettings) *goanalysis.Linter {
} }
return goanalysis.NewLinter( return goanalysis.NewLinter(
dogsledName, name,
"Checks assignments with too many blank identifiers (e.g. x, _, _, _, := f())", "Checks assignments with too many blank identifiers (e.g. x, _, _, _, := f())",
[]*analysis.Analyzer{analyzer}, []*analysis.Analyzer{analyzer},
nil, nil,
@ -100,7 +100,7 @@ func (v *returnsVisitor) Visit(node ast.Node) ast.Visitor {
if numBlank > v.maxBlanks { if numBlank > v.maxBlanks {
v.issues = append(v.issues, result.Issue{ v.issues = append(v.issues, result.Issue{
FromLinter: dogsledName, FromLinter: name,
Text: fmt.Sprintf("declaration has %v blank identifiers", numBlank), Text: fmt.Sprintf("declaration has %v blank identifiers", numBlank),
Pos: v.f.Position(assgnStmt.Pos()), Pos: v.f.Position(assgnStmt.Pos()),
}) })

View File

@ -0,0 +1,11 @@
package dogsled
import (
"testing"
"github.com/golangci/golangci-lint/test/testshared/integration"
)
func TestFromTestdata(t *testing.T) {
integration.RunTestdata(t)
}

View File

@ -1,4 +1,4 @@
package golinters package dupl
import ( import (
"fmt" "fmt"
@ -16,14 +16,14 @@ import (
"github.com/golangci/golangci-lint/pkg/result" "github.com/golangci/golangci-lint/pkg/result"
) )
const duplName = "dupl" const name = "dupl"
func NewDupl(settings *config.DuplSettings) *goanalysis.Linter { func New(settings *config.DuplSettings) *goanalysis.Linter {
var mu sync.Mutex var mu sync.Mutex
var resIssues []goanalysis.Issue var resIssues []goanalysis.Issue
analyzer := &analysis.Analyzer{ analyzer := &analysis.Analyzer{
Name: duplName, Name: name,
Doc: goanalysis.TheOnlyanalyzerDoc, Doc: goanalysis.TheOnlyanalyzerDoc,
Run: func(pass *analysis.Pass) (any, error) { Run: func(pass *analysis.Pass) (any, error) {
issues, err := runDupl(pass, settings) issues, err := runDupl(pass, settings)
@ -44,7 +44,7 @@ func NewDupl(settings *config.DuplSettings) *goanalysis.Linter {
} }
return goanalysis.NewLinter( return goanalysis.NewLinter(
duplName, name,
"Tool for code clone detection", "Tool for code clone detection",
[]*analysis.Analyzer{analyzer}, []*analysis.Analyzer{analyzer},
nil, nil,
@ -88,7 +88,7 @@ func runDupl(pass *analysis.Pass, settings *config.DuplSettings) ([]goanalysis.I
To: i.From.LineEnd(), To: i.From.LineEnd(),
}, },
Text: text, Text: text,
FromLinter: duplName, FromLinter: name,
}, pass)) }, pass))
} }

View File

@ -0,0 +1,11 @@
package dupl
import (
"testing"
"github.com/golangci/golangci-lint/test/testshared/integration"
)
func TestFromTestdata(t *testing.T) {
integration.RunTestdata(t)
}

View File

@ -1,5 +1,5 @@
//golangcitest:args -Edupl //golangcitest:args -Edupl
//golangcitest:config_path testdata/configs/dupl.yml //golangcitest:config_path testdata/dupl.yml
package testdata package testdata
type DuplLogger struct{} type DuplLogger struct{}

View File

@ -1,4 +1,4 @@
package golinters package dupword
import ( import (
"strings" "strings"
@ -10,7 +10,7 @@ import (
"github.com/golangci/golangci-lint/pkg/goanalysis" "github.com/golangci/golangci-lint/pkg/goanalysis"
) )
func NewDupWord(setting *config.DupWordSettings) *goanalysis.Linter { func New(setting *config.DupWordSettings) *goanalysis.Linter {
a := dupword.NewAnalyzer() a := dupword.NewAnalyzer()
cfgMap := map[string]map[string]any{} cfgMap := map[string]map[string]any{}

View File

@ -0,0 +1,11 @@
package dupword
import (
"testing"
"github.com/golangci/golangci-lint/test/testshared/integration"
)
func TestFromTestdata(t *testing.T) {
integration.RunTestdata(t)
}

View File

@ -1,5 +1,5 @@
//golangcitest:args -Edupword //golangcitest:args -Edupword
//golangcitest:config_path testdata/configs/dupword_ignore_the.yml //golangcitest:config_path testdata/dupword_ignore_the.yml
package testdata package testdata
import "fmt" import "fmt"

View File

@ -1,4 +1,4 @@
package golinters package durationcheck
import ( import (
"github.com/charithe/durationcheck" "github.com/charithe/durationcheck"
@ -7,7 +7,7 @@ import (
"github.com/golangci/golangci-lint/pkg/goanalysis" "github.com/golangci/golangci-lint/pkg/goanalysis"
) )
func NewDurationCheck() *goanalysis.Linter { func New() *goanalysis.Linter {
a := durationcheck.Analyzer a := durationcheck.Analyzer
return goanalysis.NewLinter( return goanalysis.NewLinter(

View File

@ -0,0 +1,11 @@
package durationcheck
import (
"testing"
"github.com/golangci/golangci-lint/test/testshared/integration"
)
func TestFromTestdata(t *testing.T) {
integration.RunTestdata(t)
}

View File

@ -1,4 +1,4 @@
package golinters package err113
import ( import (
"github.com/Djarvur/go-err113" "github.com/Djarvur/go-err113"
@ -7,7 +7,7 @@ import (
"github.com/golangci/golangci-lint/pkg/goanalysis" "github.com/golangci/golangci-lint/pkg/goanalysis"
) )
func NewErr113() *goanalysis.Linter { func New() *goanalysis.Linter {
a := err113.NewAnalyzer() a := err113.NewAnalyzer()
return goanalysis.NewLinter( return goanalysis.NewLinter(

View File

@ -0,0 +1,11 @@
package err113
import (
"testing"
"github.com/golangci/golangci-lint/test/testshared/integration"
)
func TestFromTestdata(t *testing.T) {
integration.RunTestdata(t)
}

View File

@ -1,4 +1,4 @@
package golinters package errcheck
import ( import (
"bufio" "bufio"
@ -22,20 +22,20 @@ import (
"github.com/golangci/golangci-lint/pkg/result" "github.com/golangci/golangci-lint/pkg/result"
) )
const errcheckName = "errcheck" const name = "errcheck"
func NewErrcheck(settings *config.ErrcheckSettings) *goanalysis.Linter { func New(settings *config.ErrcheckSettings) *goanalysis.Linter {
var mu sync.Mutex var mu sync.Mutex
var resIssues []goanalysis.Issue var resIssues []goanalysis.Issue
analyzer := &analysis.Analyzer{ analyzer := &analysis.Analyzer{
Name: errcheckName, Name: name,
Doc: goanalysis.TheOnlyanalyzerDoc, Doc: goanalysis.TheOnlyanalyzerDoc,
Run: goanalysis.DummyRun, Run: goanalysis.DummyRun,
} }
return goanalysis.NewLinter( return goanalysis.NewLinter(
errcheckName, name,
"errcheck is a program for checking for unchecked errors in Go code. "+ "errcheck is a program for checking for unchecked errors in Go code. "+
"These unchecked errors can be critical bugs in some cases", "These unchecked errors can be critical bugs in some cases",
[]*analysis.Analyzer{analyzer}, []*analysis.Analyzer{analyzer},
@ -100,7 +100,7 @@ func runErrCheck(lintCtx *linter.Context, pass *analysis.Pass, checker *errcheck
issues[i] = goanalysis.NewIssue( issues[i] = goanalysis.NewIssue(
&result.Issue{ &result.Issue{
FromLinter: errcheckName, FromLinter: name,
Text: text, Text: text,
Pos: err.Pos, Pos: err.Pos,
}, },

View File

@ -0,0 +1,11 @@
package errcheck
import (
"testing"
"github.com/golangci/golangci-lint/test/testshared/integration"
)
func TestFromTestdata(t *testing.T) {
integration.RunTestdata(t)
}

View File

@ -1,5 +1,5 @@
//golangcitest:args -Eerrcheck //golangcitest:args -Eerrcheck
//golangcitest:config_path testdata/configs/errcheck_exclude.yml //golangcitest:config_path testdata/errcheck_exclude.yml
package testdata package testdata
import ( import (

View File

@ -1,5 +1,5 @@
//golangcitest:args -Eerrcheck //golangcitest:args -Eerrcheck
//golangcitest:config_path testdata/configs/errcheck_exclude_functions.yml //golangcitest:config_path testdata/errcheck_exclude_functions.yml
package testdata package testdata
import ( import (

View File

@ -1,5 +1,5 @@
//golangcitest:args -Eerrcheck //golangcitest:args -Eerrcheck
//golangcitest:config_path testdata/configs/errcheck_ignore_config.yml //golangcitest:config_path testdata/errcheck_ignore_config.yml
package testdata package testdata
import ( import (

View File

@ -1,5 +1,5 @@
//golangcitest:args -Eerrcheck //golangcitest:args -Eerrcheck
//golangcitest:config_path testdata/configs/errcheck_ignore_default.yml //golangcitest:config_path testdata/errcheck_ignore_default.yml
package testdata package testdata
import ( import (

View File

@ -1,5 +1,5 @@
//golangcitest:args -Eerrcheck //golangcitest:args -Eerrcheck
//golangcitest:config_path testdata/configs/errcheck_type_assertions.yml //golangcitest:config_path testdata/errcheck_type_assertions.yml
//golangcitest:expected_exitcode 0 //golangcitest:expected_exitcode 0
package testdata package testdata

View File

@ -1,4 +1,4 @@
package golinters package errchkjson
import ( import (
"github.com/breml/errchkjson" "github.com/breml/errchkjson"
@ -8,7 +8,7 @@ import (
"github.com/golangci/golangci-lint/pkg/goanalysis" "github.com/golangci/golangci-lint/pkg/goanalysis"
) )
func NewErrChkJSON(cfg *config.ErrChkJSONSettings) *goanalysis.Linter { func New(cfg *config.ErrChkJSONSettings) *goanalysis.Linter {
a := errchkjson.NewAnalyzer() a := errchkjson.NewAnalyzer()
cfgMap := map[string]map[string]any{} cfgMap := map[string]map[string]any{}

View File

@ -0,0 +1,11 @@
package errchkjson
import (
"testing"
"github.com/golangci/golangci-lint/test/testshared/integration"
)
func TestFromTestdata(t *testing.T) {
integration.RunTestdata(t)
}

View File

@ -1,5 +1,5 @@
//golangcitest:args -Eerrchkjson //golangcitest:args -Eerrchkjson
//golangcitest:config_path testdata/configs/errchkjson.yml //golangcitest:config_path testdata/errchkjson.yml
package testdata package testdata
import ( import (

View File

@ -1,5 +1,5 @@
//golangcitest:args -Eerrchkjson //golangcitest:args -Eerrchkjson
//golangcitest:config_path testdata/configs/errchkjson_check_error_free_encoding.yml //golangcitest:config_path testdata/errchkjson_check_error_free_encoding.yml
package testdata package testdata
import ( import (

View File

@ -1,5 +1,5 @@
//golangcitest:args -Eerrchkjson //golangcitest:args -Eerrchkjson
//golangcitest:config_path testdata/configs/errchkjson_no_exported.yml //golangcitest:config_path testdata/errchkjson_no_exported.yml
package testdata package testdata
import ( import (

View File

@ -1,4 +1,4 @@
package golinters package errname
import ( import (
"github.com/Antonboom/errname/pkg/analyzer" "github.com/Antonboom/errname/pkg/analyzer"
@ -7,7 +7,7 @@ import (
"github.com/golangci/golangci-lint/pkg/goanalysis" "github.com/golangci/golangci-lint/pkg/goanalysis"
) )
func NewErrName() *goanalysis.Linter { func New() *goanalysis.Linter {
a := analyzer.New() a := analyzer.New()
return goanalysis.NewLinter( return goanalysis.NewLinter(

View File

@ -0,0 +1,11 @@
package errname
import (
"testing"
"github.com/golangci/golangci-lint/test/testshared/integration"
)
func TestFromTestdata(t *testing.T) {
integration.RunTestdata(t)
}

View File

@ -1,4 +1,4 @@
package golinters package errorlint
import ( import (
"github.com/polyfloyd/go-errorlint/errorlint" "github.com/polyfloyd/go-errorlint/errorlint"
@ -8,7 +8,7 @@ import (
"github.com/golangci/golangci-lint/pkg/goanalysis" "github.com/golangci/golangci-lint/pkg/goanalysis"
) )
func NewErrorLint(cfg *config.ErrorLintSettings) *goanalysis.Linter { func New(cfg *config.ErrorLintSettings) *goanalysis.Linter {
a := errorlint.NewAnalyzer() a := errorlint.NewAnalyzer()
cfgMap := map[string]map[string]any{} cfgMap := map[string]map[string]any{}

View File

@ -0,0 +1,11 @@
package errorlint
import (
"testing"
"github.com/golangci/golangci-lint/test/testshared/integration"
)
func TestFromTestdata(t *testing.T) {
integration.RunTestdata(t)
}

View File

@ -1,5 +1,5 @@
//golangcitest:args -Eerrorlint //golangcitest:args -Eerrorlint
//golangcitest:config_path testdata/configs/errorlint_asserts.yml //golangcitest:config_path testdata/errorlint_asserts.yml
package testdata package testdata
import ( import (

View File

@ -1,5 +1,5 @@
//golangcitest:args -Eerrorlint //golangcitest:args -Eerrorlint
//golangcitest:config_path testdata/configs/errorlint_comparison.yml //golangcitest:config_path testdata/errorlint_comparison.yml
package testdata package testdata
import ( import (

View File

@ -1,5 +1,5 @@
//golangcitest:args -Eerrorlint //golangcitest:args -Eerrorlint
//golangcitest:config_path testdata/configs/errorlint_errorf.yml //golangcitest:config_path testdata/errorlint_errorf.yml
package testdata package testdata
import ( import (

View File

@ -1,4 +1,4 @@
package golinters package execinquery
import ( import (
"github.com/lufeee/execinquery" "github.com/lufeee/execinquery"
@ -7,7 +7,7 @@ import (
"github.com/golangci/golangci-lint/pkg/goanalysis" "github.com/golangci/golangci-lint/pkg/goanalysis"
) )
func NewExecInQuery() *goanalysis.Linter { func New() *goanalysis.Linter {
a := execinquery.Analyzer a := execinquery.Analyzer
return goanalysis.NewLinter( return goanalysis.NewLinter(

View File

@ -0,0 +1,11 @@
package execinquery
import (
"testing"
"github.com/golangci/golangci-lint/test/testshared/integration"
)
func TestFromTestdata(t *testing.T) {
integration.RunTestdata(t)
}

View File

@ -1,4 +1,4 @@
package golinters package exhaustive
import ( import (
"github.com/nishanths/exhaustive" "github.com/nishanths/exhaustive"
@ -8,7 +8,7 @@ import (
"github.com/golangci/golangci-lint/pkg/goanalysis" "github.com/golangci/golangci-lint/pkg/goanalysis"
) )
func NewExhaustive(settings *config.ExhaustiveSettings) *goanalysis.Linter { func New(settings *config.ExhaustiveSettings) *goanalysis.Linter {
a := exhaustive.Analyzer a := exhaustive.Analyzer
var cfg map[string]map[string]any var cfg map[string]map[string]any

Some files were not shown because too many files have changed in this diff Show More