Skip to content

Commit 56dde9a

Browse files
committed
chore: groups gochecknoinits files to a package
1 parent 51f7ba4 commit 56dde9a

File tree

4 files changed

+19
-7
lines changed

4 files changed

+19
-7
lines changed

pkg/golinters/gochecknoinits.go renamed to pkg/golinters/gochecknoinits/gochecknoinits.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package golinters
1+
package gochecknoinits
22

33
import (
44
"fmt"
@@ -14,14 +14,14 @@ import (
1414
"github.com/golangci/golangci-lint/pkg/result"
1515
)
1616

17-
const gochecknoinitsName = "gochecknoinits"
17+
const name = "gochecknoinits"
1818

19-
func NewGochecknoinits() *goanalysis.Linter {
19+
func New() *goanalysis.Linter {
2020
var mu sync.Mutex
2121
var resIssues []goanalysis.Issue
2222

2323
analyzer := &analysis.Analyzer{
24-
Name: gochecknoinitsName,
24+
Name: name,
2525
Doc: goanalysis.TheOnlyanalyzerDoc,
2626
Run: func(pass *analysis.Pass) (any, error) {
2727
var res []goanalysis.Issue
@@ -44,7 +44,7 @@ func NewGochecknoinits() *goanalysis.Linter {
4444
}
4545

4646
return goanalysis.NewLinter(
47-
gochecknoinitsName,
47+
name,
4848
"Checks that no init functions are present in Go code",
4949
[]*analysis.Analyzer{analyzer},
5050
nil,
@@ -66,7 +66,7 @@ func checkFileForInits(f *ast.File, fset *token.FileSet) []result.Issue {
6666
res = append(res, result.Issue{
6767
Pos: fset.Position(funcDecl.Pos()),
6868
Text: fmt.Sprintf("don't use %s function", internal.FormatCode(name, nil)),
69-
FromLinter: gochecknoinitsName,
69+
FromLinter: name,
7070
})
7171
}
7272
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package gochecknoinits
2+
3+
import (
4+
"testing"
5+
6+
"github.com/golangci/golangci-lint/test/testshared/integration"
7+
)
8+
9+
func TestFromTestdata(t *testing.T) {
10+
integration.RunTestdata(t)
11+
}

pkg/lint/lintersdb/builder_linter.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import (
3434
"github.com/golangci/golangci-lint/pkg/golinters/ginkgolinter"
3535
"github.com/golangci/golangci-lint/pkg/golinters/gocheckcompilerdirectives"
3636
"github.com/golangci/golangci-lint/pkg/golinters/gochecknoglobals"
37+
"github.com/golangci/golangci-lint/pkg/golinters/gochecknoinits"
3738
"github.com/golangci/golangci-lint/pkg/golinters/gocritic"
3839
"github.com/golangci/golangci-lint/pkg/golinters/godot"
3940
"github.com/golangci/golangci-lint/pkg/golinters/gofmt"
@@ -263,7 +264,7 @@ func (LinterBuilder) Build(cfg *config.Config) ([]*linter.Config, error) {
263264
WithLoadForGoAnalysis().
264265
WithURL("https://github.com/leighmcculloch/gochecknoglobals"),
265266

266-
linter.NewConfig(golinters.NewGochecknoinits()).
267+
linter.NewConfig(gochecknoinits.New()).
267268
WithSince("v1.12.0").
268269
WithPresets(linter.PresetStyle),
269270

0 commit comments

Comments
 (0)