Skip to content

Commit cd038af

Browse files
committed
chore: groups gocognit files to a package
1 parent 21eae66 commit cd038af

File tree

5 files changed

+19
-7
lines changed

5 files changed

+19
-7
lines changed

pkg/golinters/gocognit.go renamed to pkg/golinters/gocognit/gocognit.go

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

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

18-
const gocognitName = "gocognit"
18+
const name = "gocognit"
1919

20-
func NewGocognit(settings *config.GocognitSettings) *goanalysis.Linter {
20+
func New(settings *config.GocognitSettings) *goanalysis.Linter {
2121
var mu sync.Mutex
2222
var resIssues []goanalysis.Issue
2323

@@ -40,7 +40,7 @@ func NewGocognit(settings *config.GocognitSettings) *goanalysis.Linter {
4040
}
4141

4242
return goanalysis.NewLinter(
43-
gocognitName,
43+
name,
4444
"Computes and checks the cognitive complexity of functions",
4545
[]*analysis.Analyzer{analyzer},
4646
nil,
@@ -72,7 +72,7 @@ func runGocognit(pass *analysis.Pass, settings *config.GocognitSettings) []goana
7272
Pos: s.Pos,
7373
Text: fmt.Sprintf("cognitive complexity %d of func %s is high (> %d)",
7474
s.Complexity, internal.FormatCode(s.FuncName, nil), settings.MinComplexity),
75-
FromLinter: gocognitName,
75+
FromLinter: name,
7676
}, pass))
7777
}
7878

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package gocognit
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+
}

test/testdata/gocognit.go renamed to pkg/golinters/gocognit/testdata/gocognit.go

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

55
func GoCognit_CC4_GetWords(number int) string { // want "cognitive complexity 4 of func .* is high .*"

pkg/lint/lintersdb/builder_linter.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ import (
3636
"github.com/golangci/golangci-lint/pkg/golinters/gochecknoglobals"
3737
"github.com/golangci/golangci-lint/pkg/golinters/gochecknoinits"
3838
"github.com/golangci/golangci-lint/pkg/golinters/gochecksumtype"
39+
"github.com/golangci/golangci-lint/pkg/golinters/gocognit"
3940
"github.com/golangci/golangci-lint/pkg/golinters/gocritic"
4041
"github.com/golangci/golangci-lint/pkg/golinters/godot"
4142
"github.com/golangci/golangci-lint/pkg/golinters/gofmt"
@@ -275,7 +276,7 @@ func (LinterBuilder) Build(cfg *config.Config) ([]*linter.Config, error) {
275276
WithLoadForGoAnalysis().
276277
WithURL("https://github.com/alecthomas/go-check-sumtype"),
277278

278-
linter.NewConfig(golinters.NewGocognit(&cfg.LintersSettings.Gocognit)).
279+
linter.NewConfig(gocognit.New(&cfg.LintersSettings.Gocognit)).
279280
WithSince("v1.20.0").
280281
WithPresets(linter.PresetComplexity).
281282
WithURL("https://github.com/uudashr/gocognit"),

0 commit comments

Comments
 (0)