Skip to content

Commit 557518c

Browse files
authored
Merge pull request #488 from akhilerm/update-golangci-v2
ci: update golangci-lint to v2
2 parents 4b8f9f5 + 7fe767c commit 557518c

File tree

4 files changed

+168
-162
lines changed

4 files changed

+168
-162
lines changed

.github/workflows/golangci-lint.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@ jobs:
1717
go-version: '1.22'
1818
check-latest: true
1919
- name: golangci-lint
20-
uses: golangci/golangci-lint-action@55c2c1448f86e01eaae002a5a3a9624417608d84 # v6.5.2
20+
uses: golangci/golangci-lint-action@1481404843c368bc19ca9406f87d6e0fc97bdcfd # v7.0.0
2121
with:
22-
version: v1.64
22+
version: v2.0.1

.golangci.yml

Lines changed: 163 additions & 153 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,8 @@
1-
---
1+
version: "2"
22
run:
33
concurrency: 6
4-
timeout: 5m
5-
issues:
6-
exclude-rules:
7-
# counterfeiter fakes are usually named 'fake_<something>.go'
8-
- path: fake_.*\.go
9-
linters:
10-
- gocritic
11-
- golint
12-
- dupl
13-
- linters:
14-
- goerr113
15-
text: do not define dynamic errors
16-
17-
# Maximum issues count per one linter. Set to 0 to disable. Default is 50.
18-
max-issues-per-linter: 0
19-
20-
# Maximum count of issues with the same text. Set to 0 to disable. Default is 3.
21-
max-same-issues: 0
224
linters:
23-
disable-all: true
5+
default: none
246
enable:
257
- asasalint
268
- asciicheck
@@ -39,7 +21,6 @@ linters:
3921
- errorlint
4022
- exhaustive
4123
- forcetypeassert
42-
- gci
4324
- ginkgolinter
4425
- gocheckcompilerdirectives
4526
- gochecknoinits
@@ -49,14 +30,10 @@ linters:
4930
- gocyclo
5031
- godot
5132
- godox
52-
- gofmt
53-
- gofumpt
5433
- goheader
55-
- goimports
5634
- gomoddirectives
5735
- gomodguard
5836
- goprintffuncname
59-
- gosimple
6037
- gosmopolitan
6138
- govet
6239
- grouper
@@ -85,14 +62,11 @@ linters:
8562
- sloglint
8663
- sqlclosecheck
8764
- staticcheck
88-
- stylecheck
8965
- tagalign
90-
- tenv
9166
- testableexamples
9267
- testifylint
9368
- thelper
9469
- tparallel
95-
- typecheck
9670
- unconvert
9771
- unparam
9872
- unused
@@ -121,128 +95,164 @@ linters:
12195
# - varnamelen
12296
# - wrapcheck
12397
# - wsl
124-
linters-settings:
125-
godox:
126-
keywords:
127-
- BUG
128-
- FIXME
129-
- HACK
130-
errcheck:
131-
check-type-assertions: true
132-
check-blank: true
133-
gocritic:
134-
enabled-checks:
135-
- appendAssign
136-
- appendCombine
137-
- argOrder
138-
- assignOp
139-
- badCall
140-
- badCond
141-
- badLock
142-
- badRegexp
143-
- badSorting
144-
- boolExprSimplify
145-
- builtinShadow
146-
- builtinShadowDecl
147-
- captLocal
148-
- caseOrder
149-
- codegenComment
150-
- commentFormatting
151-
- commentedOutCode
152-
- commentedOutImport
153-
- defaultCaseOrder
154-
- deferInLoop
155-
- deferUnlambda
156-
- deprecatedComment
157-
- docStub
158-
- dupArg
159-
- dupBranchBody
160-
- dupCase
161-
- dupImport
162-
- dupSubExpr
163-
- dynamicFmtString
164-
- elseif
165-
- emptyDecl
166-
- emptyFallthrough
167-
- emptyStringTest
168-
- equalFold
169-
- evalOrder
170-
- exitAfterDefer
171-
- exposedSyncMutex
172-
- externalErrorReassign
173-
- filepathJoin
174-
- flagDeref
175-
- flagName
176-
- hexLiteral
177-
- httpNoBody
178-
- hugeParam
179-
- ifElseChain
180-
- importShadow
181-
- indexAlloc
182-
- initClause
183-
- mapKey
184-
- methodExprCall
185-
- nestingReduce
186-
- newDeref
187-
- nilValReturn
188-
- octalLiteral
189-
- offBy1
190-
- paramTypeCombine
191-
- preferDecodeRune
192-
- preferFilepathJoin
193-
- preferFprint
194-
- preferStringWriter
195-
- preferWriteByte
196-
- ptrToRefParam
197-
- rangeExprCopy
198-
- rangeValCopy
199-
- redundantSprint
200-
- regexpMust
201-
- regexpPattern
202-
- regexpSimplify
203-
- returnAfterHttpError
204-
- ruleguard
205-
- singleCaseSwitch
206-
- sliceClear
207-
- sloppyLen
208-
- sloppyReassign
209-
- sloppyTypeAssert
210-
- sortSlice
211-
- sprintfQuotedString
212-
- sqlQuery
213-
- stringConcatSimplify
214-
- stringXbytes
215-
- stringsCompare
216-
- switchTrue
217-
- syncMapLoadAndDelete
218-
- timeExprSimplify
219-
- todoCommentWithoutDetail
220-
- tooManyResultsChecker
221-
- truncateCmp
222-
- typeAssertChain
223-
- typeDefFirst
224-
- typeSwitchVar
225-
- typeUnparen
226-
- uncheckedInlineErr
227-
- underef
228-
- unlabelStmt
229-
- unlambda
230-
- unnamedResult
231-
- unnecessaryBlock
232-
- unnecessaryDefer
233-
- unslice
234-
- valSwap
235-
- weakCond
236-
- whyNoLint
237-
- wrapperFunc
238-
- yodaStyleExpr
239-
nolintlint:
240-
# Enable to ensure that nolint directives are all used. Default is true.
241-
allow-unused: false
242-
# Exclude following linters from requiring an explanation. Default is [].
243-
allow-no-explanation: []
244-
# Enable to require an explanation of nonzero length after each nolint directive. Default is false.
245-
# TODO(lint): Enforce explanations for `nolint` directives
246-
require-explanation: false
247-
# Enable to require nolint directives to mention the specific linter being suppressed. Default is false.
248-
require-specific: true
98+
settings:
99+
errcheck:
100+
check-type-assertions: true
101+
check-blank: true
102+
gocritic:
103+
enabled-checks:
104+
- appendCombine
105+
- badLock
106+
- badRegexp
107+
- badSorting
108+
- boolExprSimplify
109+
- builtinShadow
110+
- builtinShadowDecl
111+
- commentedOutCode
112+
- commentedOutImport
113+
- deferInLoop
114+
- deferUnlambda
115+
- docStub
116+
- dupImport
117+
- dynamicFmtString
118+
- emptyDecl
119+
- emptyFallthrough
120+
- emptyStringTest
121+
- equalFold
122+
- evalOrder
123+
- exposedSyncMutex
124+
- externalErrorReassign
125+
- filepathJoin
126+
- hexLiteral
127+
- httpNoBody
128+
- hugeParam
129+
- importShadow
130+
- indexAlloc
131+
- initClause
132+
- methodExprCall
133+
- nestingReduce
134+
- nilValReturn
135+
- octalLiteral
136+
- paramTypeCombine
137+
- preferDecodeRune
138+
- preferFilepathJoin
139+
- preferFprint
140+
- preferStringWriter
141+
- preferWriteByte
142+
- ptrToRefParam
143+
- rangeExprCopy
144+
- rangeValCopy
145+
- redundantSprint
146+
- regexpPattern
147+
- regexpSimplify
148+
- returnAfterHttpError
149+
- ruleguard
150+
- sliceClear
151+
- sloppyReassign
152+
- sortSlice
153+
- sprintfQuotedString
154+
- sqlQuery
155+
- stringConcatSimplify
156+
- stringXbytes
157+
- stringsCompare
158+
- syncMapLoadAndDelete
159+
- timeExprSimplify
160+
- todoCommentWithoutDetail
161+
- tooManyResultsChecker
162+
- truncateCmp
163+
- typeAssertChain
164+
- typeDefFirst
165+
- typeUnparen
166+
- uncheckedInlineErr
167+
- unlabelStmt
168+
- unnamedResult
169+
- unnecessaryBlock
170+
- unnecessaryDefer
171+
- weakCond
172+
- whyNoLint
173+
- yodaStyleExpr
174+
# - appendAssign
175+
# - argOrder
176+
# - assignOp
177+
# - badCall
178+
# - badCond
179+
# - captLocal
180+
# - caseOrder
181+
# - codegenComment
182+
# - commentFormatting
183+
# - defaultCaseOrder
184+
# - deprecatedComment
185+
# - dupArg
186+
# - dupBranchBody
187+
# - dupCase
188+
# - dupSubExpr
189+
# - elseif
190+
# - exitAfterDefer
191+
# - flagDeref
192+
# - flagName
193+
# - ifElseChain
194+
# - mapKey
195+
# - newDeref
196+
# - offBy1
197+
# - regexpMust
198+
# - singleCaseSwitch
199+
# - sloppyLen
200+
# - sloppyTypeAssert
201+
# - switchTrue
202+
# - typeSwitchVar
203+
# - underef
204+
# - unlambda
205+
# - unslice
206+
# - valSwap
207+
# - wrapperFunc
208+
godox:
209+
keywords:
210+
- BUG
211+
- FIXME
212+
- HACK
213+
nolintlint:
214+
require-explanation: false
215+
require-specific: true
216+
allow-unused: false
217+
exclusions:
218+
generated: lax
219+
presets:
220+
- comments
221+
- common-false-positives
222+
- legacy
223+
- std-error-handling
224+
rules:
225+
- linters:
226+
- dupl
227+
- gocritic
228+
- golint
229+
# counterfeiter fakes are usually named 'fake_<something>.go'
230+
path: fake_.*\.go
231+
- linters:
232+
- err113
233+
text: do not define dynamic errors
234+
paths:
235+
- third_party$
236+
- builtin$
237+
- examples$
238+
issues:
239+
# Maximum issues count per one linter.
240+
# Set to 0 to disable.
241+
# Default: 50
242+
max-issues-per-linter: 0
243+
# Maximum count of issues with the same text.
244+
# Set to 0 to disable.
245+
# Default: 3
246+
max-same-issues: 0
247+
formatters:
248+
enable:
249+
- gci
250+
- gofmt
251+
- gofumpt
252+
- goimports
253+
exclusions:
254+
generated: lax
255+
paths:
256+
- third_party$
257+
- builtin$
258+
- examples$

cmd/validate-rules/staging/validate.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ func EnsureStagingDirectoriesExist(rules *config.RepositoryRules, baseBranch str
5454
// ensure all the mentioned directories exist
5555
for _, dir := range branchRule.Source.Dirs {
5656
_, directory := filepath.Split(dir)
57-
if !(baseBranch == defaultBranch || (baseBranch != defaultBranch && baseBranch == branchRule.Source.Branch)) {
57+
if baseBranch != defaultBranch && baseBranch != branchRule.Source.Branch {
5858
glog.Infof("Skipping branch %q for repository %q", branchRule.Source.Branch, directory)
5959
continue
6060
}
@@ -65,7 +65,7 @@ func EnsureStagingDirectoriesExist(rules *config.RepositoryRules, baseBranch str
6565
}
6666

6767
for _, dependency := range branchRule.Dependencies {
68-
if !(baseBranch == defaultBranch || (baseBranch != defaultBranch && baseBranch == dependency.Branch)) {
68+
if baseBranch != defaultBranch && baseBranch != dependency.Branch {
6969
glog.Infof("Skipping branch %q for dependency %q", dependency.Branch, dependency.Repository)
7070
continue
7171
}

pkg/git/mainline.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,7 @@ func FirstParent(r *gogit.Repository, c *object.Commit) (*object.Commit, error)
4545
// of visited commits.
4646
func FirstParentList(r *gogit.Repository, c *object.Commit) ([]*object.Commit, error) {
4747
l := []*object.Commit{}
48-
for {
49-
if c == nil {
50-
break
51-
}
52-
48+
for c != nil {
5349
l = append(l, c)
5450

5551
// continue with first parent if there is one

0 commit comments

Comments
 (0)