Skip to content

Commit 90cd7a0

Browse files
committed
chore: update implementation
1 parent 5b4813c commit 90cd7a0

File tree

2 files changed

+3
-10
lines changed

2 files changed

+3
-10
lines changed

pkg/golinters/prealloc/prealloc.go

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,10 @@ func New(settings *config.PreallocSettings) *goanalysis.Linter {
1414
Name: "prealloc",
1515
Doc: "Find slice declarations that could potentially be pre-allocated",
1616
Run: func(pass *analysis.Pass) (any, error) {
17-
runPreAlloc(pass, settings)
17+
pkg.Check(pass, settings.Simple, settings.RangeLoops, settings.ForLoops)
1818

1919
return nil, nil
2020
},
2121
}).
22-
WithLoadMode(goanalysis.LoadModeSyntax)
23-
}
24-
25-
func runPreAlloc(pass *analysis.Pass, settings *config.PreallocSettings) {
26-
hints := pkg.Check(pass.Files, settings.Simple, settings.RangeLoops, settings.ForLoops)
27-
28-
for _, hint := range hints {
29-
pass.Report(hint)
30-
}
22+
WithLoadMode(goanalysis.LoadModeTypesInfo)
3123
}

pkg/lint/lintersdb/builder_linter.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -557,6 +557,7 @@ func (LinterBuilder) Build(cfg *config.Config) ([]*linter.Config, error) {
557557

558558
linter.NewConfig(prealloc.New(&cfg.Linters.Settings.Prealloc)).
559559
WithSince("v1.19.0").
560+
WithLoadForGoAnalysis().
560561
WithURL("https://github.com/alexkohler/prealloc"),
561562

562563
linter.NewConfig(predeclared.New(&cfg.Linters.Settings.Predeclared)).

0 commit comments

Comments
 (0)