Skip to content

Commit 4430a42

Browse files
committed
chore: groups prealloc files to a package
1 parent ad6380f commit 4430a42

File tree

4 files changed

+19
-7
lines changed

4 files changed

+19
-7
lines changed

pkg/golinters/prealloc.go renamed to pkg/golinters/prealloc/prealloc.go

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

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

17-
const preallocName = "prealloc"
17+
const name = "prealloc"
1818

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

2323
analyzer := &analysis.Analyzer{
24-
Name: preallocName,
24+
Name: name,
2525
Doc: goanalysis.TheOnlyanalyzerDoc,
2626
Run: func(pass *analysis.Pass) (any, error) {
2727
issues := runPreAlloc(pass, settings)
@@ -39,7 +39,7 @@ func NewPreAlloc(settings *config.PreallocSettings) *goanalysis.Linter {
3939
}
4040

4141
return goanalysis.NewLinter(
42-
preallocName,
42+
name,
4343
"Finds slice declarations that could potentially be pre-allocated",
4444
[]*analysis.Analyzer{analyzer},
4545
nil,
@@ -57,7 +57,7 @@ func runPreAlloc(pass *analysis.Pass, settings *config.PreallocSettings) []goana
5757
issues = append(issues, goanalysis.NewIssue(&result.Issue{
5858
Pos: pass.Fset.Position(hint.Pos),
5959
Text: fmt.Sprintf("Consider pre-allocating %s", internal.FormatCode(hint.DeclaredSliceName, nil)),
60-
FromLinter: preallocName,
60+
FromLinter: name,
6161
}, pass))
6262
}
6363

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package prealloc
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
@@ -79,6 +79,7 @@ import (
7979
"github.com/golangci/golangci-lint/pkg/golinters/nosprintfhostport"
8080
"github.com/golangci/golangci-lint/pkg/golinters/paralleltest"
8181
"github.com/golangci/golangci-lint/pkg/golinters/perfsprint"
82+
"github.com/golangci/golangci-lint/pkg/golinters/prealloc"
8283
"github.com/golangci/golangci-lint/pkg/golinters/protogetter"
8384
"github.com/golangci/golangci-lint/pkg/golinters/spancheck"
8485
"github.com/golangci/golangci-lint/pkg/golinters/tagalign"
@@ -593,7 +594,7 @@ func (LinterBuilder) Build(cfg *config.Config) ([]*linter.Config, error) {
593594
WithPresets(linter.PresetPerformance).
594595
WithURL("https://github.com/catenacyber/perfsprint"),
595596

596-
linter.NewConfig(golinters.NewPreAlloc(&cfg.LintersSettings.Prealloc)).
597+
linter.NewConfig(prealloc.New(&cfg.LintersSettings.Prealloc)).
597598
WithSince("v1.19.0").
598599
WithPresets(linter.PresetPerformance).
599600
WithURL("https://github.com/alexkohler/prealloc"),

0 commit comments

Comments
 (0)