Skip to content

Commit 983f9a6

Browse files
committed
chore: update linter
1 parent 9801fd6 commit 983f9a6

File tree

18 files changed

+115
-107
lines changed

18 files changed

+115
-107
lines changed

.github/workflows/ci.yml

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ on:
55
branches:
66
- master
77
pull_request:
8+
branches:
9+
- master
810

911
jobs:
1012

@@ -13,7 +15,7 @@ jobs:
1315
runs-on: ubuntu-latest
1416
env:
1517
GO_VERSION: stable
16-
GOLANGCI_LINT_VERSION: v1.63.4
18+
GOLANGCI_LINT_VERSION: v2.0
1719
CGO_ENABLED: 0
1820

1921
steps:
@@ -34,14 +36,16 @@ jobs:
3436
git diff --exit-code go.mod
3537
git diff --exit-code go.sum
3638
37-
# https://golangci-lint.run/usage/install#other-ci
38-
- name: Install golangci-lint ${{ env.GOLANGCI_LINT_VERSION }}
39-
run: |
40-
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin ${GOLANGCI_LINT_VERSION}
41-
golangci-lint --version
39+
- name: golangci-lint
40+
uses: golangci/golangci-lint-action@v7
41+
with:
42+
version: ${{ env.GOLANGCI_LINT_VERSION }}
43+
44+
- name: Tests
45+
run: make test
4246

43-
- name: Make
44-
run: make
47+
- name: Build
48+
run: make build
4549

4650
check-local-install-script:
4751
name: Installation script (local)

.github/workflows/go-cross.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
name: Compilation
2+
23
on:
34
push:
45
branches:
56
- master
67
pull_request:
8+
branches:
9+
- master
710

811
jobs:
912

.github/workflows/post-release.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
name: "Post release"
2+
23
on:
34
release:
45
types:
@@ -13,4 +14,4 @@ jobs:
1314
runs-on: ${{ matrix.os }}
1415

1516
steps:
16-
- run: curl -sSfL https://raw.githubusercontent.com/golangci/misspell/master/install-misspell.sh | sh -s -- -b "./install-misspell"
17+
- run: curl -sSfL https://raw.githubusercontent.com/golangci/misspell/HEAD/install-misspell.sh | sh -s -- -b "./install-misspell"

.github/workflows/release.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
name: "Release a tag"
2+
23
on:
34
push:
45
tags:

.golangci.yml

Lines changed: 78 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -1,96 +1,102 @@
1+
version: "2"
2+
3+
formatters:
4+
enable:
5+
- gci
6+
- gofumpt
7+
settings:
8+
gofumpt:
9+
extra-rules: true
10+
111
linters:
2-
enable-all: true
12+
default: all
313
disable:
4-
- exportloopref # deprecated
5-
- rowserrcheck # not relevant (SQL)
6-
- sqlclosecheck # not relevant (SQL)
714
- cyclop # duplicate of gocyclo
815
- dupl
16+
- err113
17+
- errcheck # FIXME(ldez) must be fixed
918
- exhaustive
1019
- exhaustruct
1120
- forbidigo
1221
- gochecknoglobals
1322
- gochecknoinits
14-
- err113
15-
- mnd
23+
- gosmopolitan
24+
- gosec # FIXME(ldez) must be fixed
1625
- lll
26+
- misspell
27+
- mnd
28+
- nakedret # FIXME(ldez) must be fixed
1729
- nilnil
1830
- nlreturn
31+
- nonamedreturns # FIXME(ldez) must be fixed
1932
- paralleltest
2033
- prealloc
34+
- rowserrcheck # not relevant (SQL)
35+
- sqlclosecheck # not relevant (SQL)
2136
- testpackage
2237
- tparallel
2338
- varnamelen
2439
- wrapcheck
25-
- wsl
26-
- misspell
27-
- gosec # FIXME(ldez) must be fixed
28-
- errcheck # FIXME(ldez) must be fixed
29-
- nonamedreturns # FIXME(ldez) must be fixed
30-
- nakedret # FIXME(ldez) must be fixed
40+
- wsl # FIXME(ldez) must be fixed
3141

32-
linters-settings:
33-
govet:
34-
enable-all: true
35-
disable:
36-
- fieldalignment
37-
gocyclo:
38-
min-complexity: 16
39-
goconst:
40-
min-len: 3
41-
min-occurrences: 3
42-
misspell:
43-
locale: US
44-
funlen:
45-
lines: -1
46-
statements: 40
47-
gofumpt:
48-
extra-rules: true
49-
depguard:
42+
settings:
43+
depguard:
44+
rules:
45+
main:
46+
deny:
47+
- pkg: github.com/instana/testify
48+
desc: not allowed
49+
- pkg: github.com/pkg/errors
50+
desc: Should be replaced by standard lib errors package
51+
forbidigo:
52+
forbid:
53+
- pattern: ^print(ln)?$
54+
- pattern: ^panic$
55+
- pattern: ^spew\.Print(f|ln)?$
56+
- pattern: ^spew\.Dump$
57+
funlen:
58+
lines: -1
59+
statements: 40
60+
goconst:
61+
min-len: 3
62+
min-occurrences: 3
63+
gocritic:
64+
disabled-checks:
65+
- sloppyReassign
66+
- rangeValCopy
67+
- octalLiteral
68+
- paramTypeCombine # already handle by gofumpt.extra-rules
69+
- exitAfterDefer # FIXME(ldez) must be fixed
70+
- ifElseChain # FIXME(ldez) must be fixed
71+
enabled-tags:
72+
- diagnostic
73+
- style
74+
- performance
75+
settings:
76+
hugeParam:
77+
sizeThreshold: 100
78+
gocyclo:
79+
min-complexity: 16
80+
godox:
81+
keywords:
82+
- FIXME
83+
govet:
84+
disable:
85+
- fieldalignment
86+
enable-all: true
87+
misspell:
88+
locale: US
89+
90+
exclusions:
91+
warn-unused: true
92+
presets:
93+
- comments
5094
rules:
51-
main:
52-
deny:
53-
- pkg: "github.com/instana/testify"
54-
desc: not allowed
55-
- pkg: "github.com/pkg/errors"
56-
desc: Should be replaced by standard lib errors package
57-
godox:
58-
keywords:
59-
- FIXME
60-
gocritic:
61-
enabled-tags:
62-
- diagnostic
63-
- style
64-
- performance
65-
disabled-checks:
66-
- sloppyReassign
67-
- rangeValCopy
68-
- octalLiteral
69-
- paramTypeCombine # already handle by gofumpt.extra-rules
70-
- exitAfterDefer # FIXME(ldez) must be fixed
71-
- ifElseChain # FIXME(ldez) must be fixed
72-
settings:
73-
hugeParam:
74-
sizeThreshold: 100
75-
forbidigo:
76-
forbid:
77-
- '^print(ln)?$'
78-
- '^panic$'
79-
- '^spew\.Print(f|ln)?$'
80-
- '^spew\.Dump$'
95+
- linters:
96+
- funlen
97+
- goconst
98+
path: .*_test.go
8199

82100
issues:
83-
exclude-use-default: false
84101
max-issues-per-linter: 0
85102
max-same-issues: 0
86-
exclude:
87-
- 'ST1000: at least one file in a package should have a package comment'
88-
- 'package-comments: should have a package comment'
89-
exclude-rules:
90-
- path: .*_test.go
91-
linters:
92-
- funlen
93-
- goconst
94-
95-
run:
96-
timeout: 2m

ascii.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ func StringEqualFold(s1, s2 string) bool {
3232
if len(s1) != len(s2) {
3333
return false
3434
}
35-
for i := 0; i < len(s1); i++ {
35+
for i := range len(s1) {
3636
c1 := s1[i]
3737
c2 := s2[i]
3838
// c1 & c2

benchmark_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ func BenchmarkCleanString(b *testing.B) {
3434
var updated string
3535
var diffs []Diff
3636
var count int
37-
for n := 0; n < b.N; n++ {
37+
for n := 0; n < b.N; n++ { //nolint:intrange // use Loop -> go1.24
3838
updated, diffs = rep.Replace(sampleClean)
3939
count += len(diffs)
4040
}
@@ -55,7 +55,7 @@ func BenchmarkCleanStream(b *testing.B) {
5555
tmpCount = 0
5656
buf := bytes.NewBufferString(sampleClean)
5757
out := bytes.NewBuffer(make([]byte, 0, len(sampleClean)+100))
58-
for n := 0; n < b.N; n++ {
58+
for n := 0; n < b.N; n++ { //nolint:intrange // use Loop -> go1.24
5959
buf.Reset()
6060
buf.WriteString(sampleClean)
6161
out.Reset()
@@ -70,7 +70,7 @@ func BenchmarkCleanStreamDiscard(b *testing.B) {
7070

7171
buf := bytes.NewBufferString(sampleClean)
7272
tmpCount = 0
73-
for n := 0; n < b.N; n++ {
73+
for n := 0; n < b.N; n++ { //nolint:intrange // use Loop -> go1.24
7474
buf.Reset()
7575
buf.WriteString(sampleClean)
7676
rep.ReplaceReader(buf, io.Discard, discardDiff)
@@ -84,7 +84,7 @@ func BenchmarkDirtyString(b *testing.B) {
8484
var updated string
8585
var diffs []Diff
8686
var count int
87-
for n := 0; n < b.N; n++ {
87+
for n := 0; n < b.N; n++ { //nolint:intrange // use Loop -> go1.24
8888
updated, diffs = rep.Replace(sampleDirty)
8989
count += len(diffs)
9090
}
@@ -98,7 +98,7 @@ func BenchmarkCompile(b *testing.B) {
9898
r := New()
9999
b.ReportAllocs()
100100
b.ResetTimer()
101-
for n := 0; n < b.N; n++ {
101+
for n := 0; n < b.N; n++ { //nolint:intrange // use Loop -> go1.24
102102
r.Compile()
103103
}
104104
}

case.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ func CaseStyle(word string) WordCase {
2121
lowerCount := 0
2222

2323
// this iterates over RUNES not BYTES
24-
for i := 0; i < len(word); i++ {
24+
for i := range len(word) {
2525
ch := word[i]
2626
switch {
2727
case ch >= 'a' && ch <= 'z':

case_test.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ func TestCaseStyle(t *testing.T) {
1919
}
2020

2121
for _, test := range testCases {
22-
test := test
2322
t.Run(test.word, func(t *testing.T) {
2423
t.Parallel()
2524

@@ -40,7 +39,6 @@ func TestCaseVariations(t *testing.T) {
4039
}
4140

4241
for _, test := range testCases {
43-
test := test
4442
t.Run(test.word, func(t *testing.T) {
4543
t.Parallel()
4644

cmd/misspell/main.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -164,10 +164,10 @@ func main() {
164164
log.Fatal(err)
165165
}
166166

167-
switch {
168-
case *format == outputFormatCSV:
167+
switch *format {
168+
case outputFormatCSV:
169169
output.Println(csvHeader)
170-
case *format == outputFormatSQLite || *format == outputFormatSQLite3:
170+
case outputFormatSQLite, outputFormatSQLite3:
171171
output.Println(sqliteHeader)
172172
}
173173

@@ -241,7 +241,7 @@ func main() {
241241
c := make(chan string, 64)
242242
results := make(chan int, *workers)
243243

244-
for i := 0; i < *workers; i++ {
244+
for range *workers {
245245
go worker(*writeit, &r, *mode, c, results)
246246
}
247247

@@ -256,7 +256,7 @@ func main() {
256256
close(c)
257257

258258
count := 0
259-
for i := 0; i < *workers; i++ {
259+
for range *workers {
260260
changed := <-results
261261
count += changed
262262
}

0 commit comments

Comments
 (0)