Skip to content

Commit e42c181

Browse files
committed
Add for-range-int support
1 parent 2881c26 commit e42c181

File tree

6 files changed

+24
-24
lines changed

6 files changed

+24
-24
lines changed

.github/workflows/test.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ jobs:
1616
strategy:
1717
matrix:
1818
os: [ubuntu-latest]
19-
os-version: ['stable']
20-
go-version: ['1.19', '1.20', '1.21', '1.22', '1.23']
19+
os-version: ["stable"]
20+
go-version: ["1.24", "1.25", "1.26"]
2121

2222
steps:
2323
- name: Checkout
@@ -30,4 +30,3 @@ jobs:
3030
cache: true
3131
- name: Run tests
3232
run: go test ./...
33-

go.mod

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
module github.com/uudashr/gocognit
22

3-
go 1.19
3+
go 1.24.0
44

5-
require golang.org/x/tools v0.23.0
5+
require golang.org/x/tools v0.42.0
66

77
require (
8-
golang.org/x/mod v0.19.0 // indirect
9-
golang.org/x/sync v0.7.0 // indirect
8+
golang.org/x/mod v0.33.0 // indirect
9+
golang.org/x/sync v0.19.0 // indirect
1010
)
1111

1212
retract v1.1.1 // Accidentally published.

go.sum

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
22
golang.org/x/mod v0.19.0 h1:fEdghXQSo20giMthA7cd28ZC+jts4amQ3YMXiP5oMQ8=
33
golang.org/x/mod v0.19.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
4+
golang.org/x/mod v0.33.0 h1:tHFzIWbBifEmbwtGz65eaWyGiGZatSrT9prnU8DbVL8=
5+
golang.org/x/mod v0.33.0/go.mod h1:swjeQEj+6r7fODbD2cqrnje9PnziFuw4bmLbBZFrQ5w=
46
golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M=
57
golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
8+
golang.org/x/sync v0.19.0 h1:vV+1eWNmZ5geRlYjzm2adRgW2/mcpevXNg50YZtPCE4=
9+
golang.org/x/sync v0.19.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI=
610
golang.org/x/tools v0.23.0 h1:SGsXPZ+2l4JsgaCKkx+FQ9YZ5XEtA1GZYuoDjenLjvg=
711
golang.org/x/tools v0.23.0/go.mod h1:pnu6ufv6vQkll6szChhK3C3L/ruaIv5eBeztNG8wtsI=
12+
golang.org/x/tools v0.42.0 h1:uNgphsn75Tdz5Ji2q36v/nsFSfR/9BRFvqhGBaJGd5k=
13+
golang.org/x/tools v0.42.0/go.mod h1:Ma6lCIwGZvHK6XtgbswSoWroEkhugApmsXyrUmBhfr0=

gocognit118_test.go

Lines changed: 0 additions & 17 deletions
This file was deleted.

gocognit_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@ func TestAnalyzerOver3(t *testing.T) {
1919
analysistest.Run(t, testdata, gocognit.Analyzer, "b")
2020
}
2121

22+
func TestAnalyzerGenerics(t *testing.T) {
23+
testdata := analysistest.TestData()
24+
gocognit.Analyzer.Flags.Set("over", "0")
25+
analysistest.Run(t, testdata, gocognit.Analyzer, "c")
26+
}
27+
2228
func TestAnalyzerComplex(t *testing.T) {
2329
testdata := analysistest.TestData()
2430
gocognit.Analyzer.Flags.Set("over", "0")

testdata/src/a/a.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,3 +284,9 @@ func SwitchInNest(w io.Writer, i interface{}) error { // want "cognitive complex
284284

285285
return errors.New("nil interface")
286286
} // total complexity = 3
287+
288+
func ForIntLoop() { // want "cognitive complexity 1 of func ForIntLoop is high \\(> 0\\)"
289+
for i := range 10 { // +1
290+
fmt.Println(i)
291+
}
292+
} // total complexity = 1

0 commit comments

Comments
 (0)