Skip to content

Commit c522a25

Browse files
committed
chore: update linter
1 parent c07a75c commit c522a25

File tree

3 files changed

+116
-126
lines changed

3 files changed

+116
-126
lines changed

.github/workflows/pr.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
runs-on: ubuntu-latest
1818
env:
1919
GO_VERSION: stable
20-
GOLANGCI_LINT_VERSION: v1.64.8
20+
GOLANGCI_LINT_VERSION: v2.0.1
2121

2222
steps:
2323
- uses: actions/checkout@v4

.golangci.yml

Lines changed: 113 additions & 123 deletions
Original file line numberDiff line numberDiff line change
@@ -1,137 +1,127 @@
1+
version: "2"
2+
3+
formatters:
4+
enable:
5+
- gci
6+
- gofumpt
7+
settings:
8+
gofumpt:
9+
extra-rules: false
10+
111
linters:
2-
enable-all: true
12+
default: all
313
disable:
4-
- tenv # deprecated
5-
- sqlclosecheck # not relevant (SQL)
6-
- rowserrcheck # not relevant (SQL)
14+
- bodyclose # Too many false positives: https://github.com/timakin/bodyclose/issues/30
715
- cyclop # duplicate of gocyclo
8-
- lll
916
- dupl
10-
- wsl
11-
- nlreturn
12-
- mnd
1317
- err113
14-
- wrapcheck
1518
- exhaustive
1619
- exhaustruct
17-
- testpackage
18-
- tparallel
19-
- paralleltest
20-
- prealloc
2120
- forcetypeassert
22-
- bodyclose # Too many false positives: https://github.com/timakin/bodyclose/issues/30
23-
- varnamelen
24-
- noctx
25-
- tagliatelle
26-
- nilnil
27-
- ireturn
28-
- nonamedreturns
2921
- gochecknoglobals # TODO(ldez) should be use on the project
30-
- nestif # TODO(ldez) should be use on the project
22+
- ireturn
23+
- lll
24+
- mnd
3125
- musttag
32-
33-
linters-settings:
34-
govet:
35-
enable-all: true
36-
disable:
37-
- fieldalignment
38-
- shadow
39-
gocyclo:
40-
min-complexity: 15
41-
goconst:
42-
min-len: 5
43-
min-occurrences: 3
44-
misspell:
45-
locale: US
46-
funlen:
47-
lines: -1
48-
statements: 50
49-
godox:
50-
keywords:
51-
- FIXME
52-
gofumpt:
53-
extra-rules: false
54-
depguard:
26+
- nestif # TODO(ldez) should be use on the project
27+
- nilnil
28+
- nlreturn
29+
- noctx
30+
- nonamedreturns
31+
- paralleltest
32+
- prealloc
33+
- rowserrcheck # not relevant (SQL)
34+
- sqlclosecheck # not relevant (SQL)
35+
- tagliatelle
36+
- testpackage
37+
- tparallel
38+
- varnamelen
39+
- wrapcheck
40+
- wsl # TODO(ldez) should be use on the project
41+
settings:
42+
depguard:
43+
rules:
44+
main:
45+
deny:
46+
- pkg: github.com/instana/testify
47+
desc: not allowed
48+
- pkg: github.com/pkg/errors
49+
desc: Should be replaced by standard lib errors package
50+
funlen:
51+
lines: -1
52+
statements: 50
53+
goconst:
54+
min-len: 5
55+
min-occurrences: 3
56+
gocritic:
57+
disabled-checks:
58+
- sloppyReassign
59+
- rangeValCopy
60+
- octalLiteral
61+
- paramTypeCombine # already handle by gofumpt.extra-rules
62+
- httpNoBody
63+
- unnamedResult
64+
- deferInLoop # TODO(ldez) should be use on the project
65+
enabled-tags:
66+
- diagnostic
67+
- style
68+
- performance
69+
settings:
70+
hugeParam:
71+
sizeThreshold: 100
72+
gocyclo:
73+
min-complexity: 15
74+
godox:
75+
keywords:
76+
- FIXME
77+
govet:
78+
disable:
79+
- fieldalignment
80+
- shadow
81+
enable-all: true
82+
misspell:
83+
locale: US
84+
perfsprint:
85+
err-error: true
86+
errorf: true
87+
sprintf1: true
88+
strconcat: false
89+
testifylint:
90+
disable:
91+
- go-require
92+
exclusions:
93+
warn-unused: true
94+
presets:
95+
- comments
96+
- std-error-handling
5597
rules:
56-
main:
57-
deny:
58-
- pkg: "github.com/instana/testify"
59-
desc: not allowed
60-
- pkg: "github.com/pkg/errors"
61-
desc: Should be replaced by standard lib errors package
62-
gocritic:
63-
enabled-tags:
64-
- diagnostic
65-
- style
66-
- performance
67-
disabled-checks:
68-
- sloppyReassign
69-
- rangeValCopy
70-
- octalLiteral
71-
- paramTypeCombine # already handle by gofumpt.extra-rules
72-
- httpNoBody
73-
- unnamedResult
74-
- deferInLoop # TODO(ldez) should be use on the project
75-
settings:
76-
hugeParam:
77-
sizeThreshold: 100
78-
testifylint:
79-
disable:
80-
- go-require
81-
perfsprint:
82-
err-error: true
83-
errorf: true
84-
sprintf1: true
85-
strconcat: false
86-
98+
- linters:
99+
- canonicalheader
100+
- funlen
101+
- goconst
102+
- gosec
103+
path: .*_test.go
104+
- linters:
105+
- gosec
106+
path: testutils/.+
107+
- path: cbreaker/cbreaker_test.go # TODO(ldez) must be fixed
108+
text: 'statsNetErrors - threshold always receives 0.6'
109+
- path: buffer/buffer.go # TODO(ldez) must be fixed
110+
text: (cognitive|cyclomatic) complexity \d+ of func `\(\*Buffer\)\.ServeHTTP` is high
111+
- path: buffer/buffer.go # TODO(ldez) must be fixed
112+
text: Function 'ServeHTTP' has too many statements
113+
- path: memmetrics/ratio_test.go # TODO(ldez) must be fixed
114+
text: 'float-compare: use assert\.InEpsilon \(or InDelta\)'
115+
- path: memmetrics/roundtrip_test.go # TODO(ldez) must be fixed
116+
text: 'float-compare: use assert\.InEpsilon \(or InDelta\)'
117+
- path: memmetrics/anomaly_test.go # TODO(ldez) must be fixed
118+
text: 'float-compare: use assert\.InEpsilon \(or InDelta\)'
119+
- path: (.+)\.go$ # TODO(ldez) must be fixed
120+
text: 'SA1019: http.CloseNotifier has been deprecated'
121+
- path: (.+)\.go$ # TODO(ldez) must be fixed
122+
text: 'exported: func name will be used as roundrobin.RoundRobinRequestRewriteListener by other packages'
123+
paths:
124+
- internal/holsterv4
87125
issues:
88-
exclude-use-default: false
89126
max-issues-per-linter: 0
90127
max-same-issues: 0
91-
exclude-dirs:
92-
- "internal/holsterv4"
93-
exclude:
94-
- 'ST1000: at least one file in a package should have a package comment' # TODO(ldez) must be fixed
95-
- 'package-comments: should have a package comment'
96-
- 'Error return value of .((os\\.)?std(out|err)\\..*|.*Close|.*Flush|os\\.Remove(All)?|.*printf?|os\\.(Un)?Setenv). is not checked'
97-
- 'SA1019: http.CloseNotifier has been deprecated'
98-
- 'exported: func name will be used as roundrobin.RoundRobinRequestRewriteListener by other packages'# TODO(ldez) must be fixed
99-
100-
exclude-rules:
101-
- path: .*_test.go
102-
linters:
103-
- funlen
104-
- gosec
105-
- goconst
106-
- canonicalheader
107-
- path: testutils/.+
108-
linters:
109-
- gosec
110-
- path: cbreaker/cbreaker_test.go
111-
text: "`statsNetErrors` - `threshold` always receives `0.6`" # TODO(ldez) must be fixed
112-
- path: buffer/buffer.go
113-
text: "(cognitive|cyclomatic) complexity \\d+ of func `\\(\\*Buffer\\)\\.ServeHTTP` is high" # TODO(ldez) must be fixed
114-
- path: buffer/buffer.go
115-
text: "Function 'ServeHTTP' has too many statements" # TODO(ldez) must be fixed
116-
- path: forward/fwd.go
117-
text: "(cognitive|cyclomatic) complexity \\d+ of func `\\(\\*httpForwarder\\)\\.serveWebSocket` is high" # TODO(ldez) must be fixed
118-
- path: forward/fwd.go
119-
text: "Function 'serveWebSocket' has too many statements" # TODO(ldez) must be fixed
120-
- path: utils/handler.go
121-
text: "ifElseChain: rewrite if-else to switch statement" # TODO(ldez) must be fixed
122-
- path: memmetrics/ratio_test.go
123-
text: "float-compare: use assert\\.InEpsilon \\(or InDelta\\)" # TODO(ldez) must be fixed
124-
- path: memmetrics/roundtrip_test.go
125-
text: "float-compare: use assert\\.InEpsilon \\(or InDelta\\)" # TODO(ldez) must be fixed
126-
- path: memmetrics/anomaly_test.go
127-
text: "float-compare: use assert\\.InEpsilon \\(or InDelta\\)" # TODO(ldez) must be fixed
128-
129-
output:
130-
show-stats: true
131-
sort-results: true
132-
sort-order:
133-
- linter
134-
- file
135-
136-
run:
137-
timeout: 5m

utils/netutils_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ func TestCopyHeaders(t *testing.T) {
4949
// make sure that altering source does not affect the destination
5050
source.Del("a")
5151

52-
assert.Equal(t, "", source.Get("a"))
52+
assert.Empty(t, source.Get("a"))
5353
assert.Equal(t, "b", destination.Get("a"))
5454
}
5555

@@ -70,7 +70,7 @@ func TestRemoveHeaders(t *testing.T) {
7070

7171
RemoveHeaders(source, "a")
7272

73-
assert.Equal(t, "", source.Get("a"))
73+
assert.Empty(t, source.Get("a"))
7474
assert.Equal(t, "d", source.Get("c"))
7575
}
7676

0 commit comments

Comments
 (0)