Skip to content

Commit ea02b9a

Browse files
committed
chore: groups goconst files to a package
1 parent cd038af commit ea02b9a

10 files changed

+22
-10
lines changed

pkg/golinters/goconst.go renamed to pkg/golinters/goconst/goconst.go

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

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

17-
const goconstName = "goconst"
17+
const name = "goconst"
1818

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

2323
analyzer := &analysis.Analyzer{
24-
Name: goconstName,
24+
Name: name,
2525
Doc: goanalysis.TheOnlyanalyzerDoc,
2626
Run: func(pass *analysis.Pass) (any, error) {
2727
issues, err := runGoconst(pass, settings)
@@ -42,7 +42,7 @@ func NewGoconst(settings *config.GoConstSettings) *goanalysis.Linter {
4242
}
4343

4444
return goanalysis.NewLinter(
45-
goconstName,
45+
name,
4646
"Finds repeated strings that could be replaced by a constant",
4747
[]*analysis.Analyzer{analyzer},
4848
nil,
@@ -90,7 +90,7 @@ func runGoconst(pass *analysis.Pass, settings *config.GoConstSettings) ([]goanal
9090
res = append(res, goanalysis.NewIssue(&result.Issue{
9191
Pos: i.Pos,
9292
Text: text,
93-
FromLinter: goconstName,
93+
FromLinter: name,
9494
}, pass))
9595
}
9696

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package goconst
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+
}
File renamed without changes.

test/testdata/goconst_calls_enabled.go renamed to pkg/golinters/goconst/testdata/goconst_calls_enabled.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//golangcitest:args -Egoconst
2-
//golangcitest:config_path testdata/configs/goconst_calls_enabled.yml
2+
//golangcitest:config_path testdata/goconst_calls_enabled.yml
33
package testdata
44

55
import "fmt"

test/testdata/goconst_dont_ignore_test.go renamed to pkg/golinters/goconst/testdata/goconst_dont_ignore_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//golangcitest:args -Egoconst
2-
//golangcitest:config_path testdata/configs/goconst_dont_ignore.yml
2+
//golangcitest:config_path testdata/goconst_dont_ignore.yml
33
package testdata
44

55
import (

test/testdata/goconst_ignore_test.go renamed to pkg/golinters/goconst/testdata/goconst_ignore_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//golangcitest:args -Egoconst
2-
//golangcitest:config_path testdata/configs/goconst_ignore.yml
2+
//golangcitest:config_path testdata/goconst_ignore.yml
33
//golangcitest:expected_exitcode 0
44
package testdata
55

pkg/lint/lintersdb/builder_linter.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ import (
3737
"github.com/golangci/golangci-lint/pkg/golinters/gochecknoinits"
3838
"github.com/golangci/golangci-lint/pkg/golinters/gochecksumtype"
3939
"github.com/golangci/golangci-lint/pkg/golinters/gocognit"
40+
"github.com/golangci/golangci-lint/pkg/golinters/goconst"
4041
"github.com/golangci/golangci-lint/pkg/golinters/gocritic"
4142
"github.com/golangci/golangci-lint/pkg/golinters/godot"
4243
"github.com/golangci/golangci-lint/pkg/golinters/gofmt"
@@ -281,7 +282,7 @@ func (LinterBuilder) Build(cfg *config.Config) ([]*linter.Config, error) {
281282
WithPresets(linter.PresetComplexity).
282283
WithURL("https://github.com/uudashr/gocognit"),
283284

284-
linter.NewConfig(golinters.NewGoconst(&cfg.LintersSettings.Goconst)).
285+
linter.NewConfig(goconst.New(&cfg.LintersSettings.Goconst)).
285286
WithSince("v1.0.0").
286287
WithPresets(linter.PresetStyle).
287288
WithURL("https://github.com/jgautheron/goconst"),

0 commit comments

Comments
 (0)