Skip to content

ci: update golangci-lint to v2 #488

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Mar 25, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ jobs:
go-version: '1.22'
check-latest: true
- name: golangci-lint
uses: golangci/golangci-lint-action@55c2c1448f86e01eaae002a5a3a9624417608d84 # v6.5.2
uses: golangci/golangci-lint-action@1481404843c368bc19ca9406f87d6e0fc97bdcfd # v7.0.0
with:
version: v1.64
version: v2.0.1
316 changes: 163 additions & 153 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,8 @@
---
version: "2"
run:
concurrency: 6
timeout: 5m
issues:
exclude-rules:
# counterfeiter fakes are usually named 'fake_<something>.go'
- path: fake_.*\.go
linters:
- gocritic
- golint
- dupl
- linters:
- goerr113
text: do not define dynamic errors

# Maximum issues count per one linter. Set to 0 to disable. Default is 50.
max-issues-per-linter: 0

# Maximum count of issues with the same text. Set to 0 to disable. Default is 3.
max-same-issues: 0
linters:
disable-all: true
default: none
enable:
- asasalint
- asciicheck
Expand All @@ -39,7 +21,6 @@ linters:
- errorlint
- exhaustive
- forcetypeassert
- gci
- ginkgolinter
- gocheckcompilerdirectives
- gochecknoinits
Expand All @@ -49,14 +30,10 @@ linters:
- gocyclo
- godot
- godox
- gofmt
- gofumpt
- goheader
- goimports
- gomoddirectives
- gomodguard
- goprintffuncname
- gosimple
- gosmopolitan
- govet
- grouper
Expand Down Expand Up @@ -85,14 +62,11 @@ linters:
- sloglint
- sqlclosecheck
- staticcheck
- stylecheck
- tagalign
- tenv
- testableexamples
- testifylint
- thelper
- tparallel
- typecheck
- unconvert
- unparam
- unused
Expand Down Expand Up @@ -121,128 +95,164 @@ linters:
# - varnamelen
# - wrapcheck
# - wsl
linters-settings:
godox:
keywords:
- BUG
- FIXME
- HACK
errcheck:
check-type-assertions: true
check-blank: true
gocritic:
enabled-checks:
- appendAssign
- appendCombine
- argOrder
- assignOp
- badCall
- badCond
- badLock
- badRegexp
- badSorting
- boolExprSimplify
- builtinShadow
- builtinShadowDecl
- captLocal
- caseOrder
- codegenComment
- commentFormatting
- commentedOutCode
- commentedOutImport
- defaultCaseOrder
- deferInLoop
- deferUnlambda
- deprecatedComment
- docStub
- dupArg
- dupBranchBody
- dupCase
- dupImport
- dupSubExpr
- dynamicFmtString
- elseif
- emptyDecl
- emptyFallthrough
- emptyStringTest
- equalFold
- evalOrder
- exitAfterDefer
- exposedSyncMutex
- externalErrorReassign
- filepathJoin
- flagDeref
- flagName
- hexLiteral
- httpNoBody
- hugeParam
- ifElseChain
- importShadow
- indexAlloc
- initClause
- mapKey
- methodExprCall
- nestingReduce
- newDeref
- nilValReturn
- octalLiteral
- offBy1
- paramTypeCombine
- preferDecodeRune
- preferFilepathJoin
- preferFprint
- preferStringWriter
- preferWriteByte
- ptrToRefParam
- rangeExprCopy
- rangeValCopy
- redundantSprint
- regexpMust
- regexpPattern
- regexpSimplify
- returnAfterHttpError
- ruleguard
- singleCaseSwitch
- sliceClear
- sloppyLen
- sloppyReassign
- sloppyTypeAssert
- sortSlice
- sprintfQuotedString
- sqlQuery
- stringConcatSimplify
- stringXbytes
- stringsCompare
- switchTrue
- syncMapLoadAndDelete
- timeExprSimplify
- todoCommentWithoutDetail
- tooManyResultsChecker
- truncateCmp
- typeAssertChain
- typeDefFirst
- typeSwitchVar
- typeUnparen
- uncheckedInlineErr
- underef
- unlabelStmt
- unlambda
- unnamedResult
- unnecessaryBlock
- unnecessaryDefer
- unslice
- valSwap
- weakCond
- whyNoLint
- wrapperFunc
- yodaStyleExpr
nolintlint:
# Enable to ensure that nolint directives are all used. Default is true.
allow-unused: false
# Exclude following linters from requiring an explanation. Default is [].
allow-no-explanation: []
# Enable to require an explanation of nonzero length after each nolint directive. Default is false.
# TODO(lint): Enforce explanations for `nolint` directives
require-explanation: false
# Enable to require nolint directives to mention the specific linter being suppressed. Default is false.
require-specific: true
settings:
errcheck:
check-type-assertions: true
check-blank: true
gocritic:
enabled-checks:
- appendCombine
- badLock
- badRegexp
- badSorting
- boolExprSimplify
- builtinShadow
- builtinShadowDecl
- commentedOutCode
- commentedOutImport
- deferInLoop
- deferUnlambda
- docStub
- dupImport
- dynamicFmtString
- emptyDecl
- emptyFallthrough
- emptyStringTest
- equalFold
- evalOrder
- exposedSyncMutex
- externalErrorReassign
- filepathJoin
- hexLiteral
- httpNoBody
- hugeParam
- importShadow
- indexAlloc
- initClause
- methodExprCall
- nestingReduce
- nilValReturn
- octalLiteral
- paramTypeCombine
- preferDecodeRune
- preferFilepathJoin
- preferFprint
- preferStringWriter
- preferWriteByte
- ptrToRefParam
- rangeExprCopy
- rangeValCopy
- redundantSprint
- regexpPattern
- regexpSimplify
- returnAfterHttpError
- ruleguard
- sliceClear
- sloppyReassign
- sortSlice
- sprintfQuotedString
- sqlQuery
- stringConcatSimplify
- stringXbytes
- stringsCompare
- syncMapLoadAndDelete
- timeExprSimplify
- todoCommentWithoutDetail
- tooManyResultsChecker
- truncateCmp
- typeAssertChain
- typeDefFirst
- typeUnparen
- uncheckedInlineErr
- unlabelStmt
- unnamedResult
- unnecessaryBlock
- unnecessaryDefer
- weakCond
- whyNoLint
- yodaStyleExpr
# - appendAssign
# - argOrder
# - assignOp
# - badCall
# - badCond
# - captLocal
# - caseOrder
# - codegenComment
# - commentFormatting
# - defaultCaseOrder
# - deprecatedComment
# - dupArg
# - dupBranchBody
# - dupCase
# - dupSubExpr
# - elseif
# - exitAfterDefer
# - flagDeref
# - flagName
# - ifElseChain
# - mapKey
# - newDeref
# - offBy1
# - regexpMust
# - singleCaseSwitch
# - sloppyLen
# - sloppyTypeAssert
# - switchTrue
# - typeSwitchVar
# - underef
# - unlambda
# - unslice
# - valSwap
# - wrapperFunc
godox:
keywords:
- BUG
- FIXME
- HACK
nolintlint:
require-explanation: false
require-specific: true
allow-unused: false
exclusions:
generated: lax
presets:
- comments
- common-false-positives
- legacy
- std-error-handling
rules:
- linters:
- dupl
- gocritic
- golint
# counterfeiter fakes are usually named 'fake_<something>.go'
path: fake_.*\.go
- linters:
- err113
text: do not define dynamic errors
paths:
- third_party$
- builtin$
- examples$
issues:
# Maximum issues count per one linter.
# Set to 0 to disable.
# Default: 50
max-issues-per-linter: 0
# Maximum count of issues with the same text.
# Set to 0 to disable.
# Default: 3
max-same-issues: 0
formatters:
enable:
- gci
- gofmt
- gofumpt
- goimports
exclusions:
generated: lax
paths:
- third_party$
- builtin$
- examples$
4 changes: 2 additions & 2 deletions cmd/validate-rules/staging/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func EnsureStagingDirectoriesExist(rules *config.RepositoryRules, baseBranch str
// ensure all the mentioned directories exist
for _, dir := range branchRule.Source.Dirs {
_, directory := filepath.Split(dir)
if !(baseBranch == defaultBranch || (baseBranch != defaultBranch && baseBranch == branchRule.Source.Branch)) {
if baseBranch != defaultBranch && baseBranch != branchRule.Source.Branch {
glog.Infof("Skipping branch %q for repository %q", branchRule.Source.Branch, directory)
continue
}
Expand All @@ -65,7 +65,7 @@ func EnsureStagingDirectoriesExist(rules *config.RepositoryRules, baseBranch str
}

for _, dependency := range branchRule.Dependencies {
if !(baseBranch == defaultBranch || (baseBranch != defaultBranch && baseBranch == dependency.Branch)) {
if baseBranch != defaultBranch && baseBranch != dependency.Branch {
glog.Infof("Skipping branch %q for dependency %q", dependency.Branch, dependency.Repository)
continue
}
Expand Down
6 changes: 1 addition & 5 deletions pkg/git/mainline.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,7 @@ func FirstParent(r *gogit.Repository, c *object.Commit) (*object.Commit, error)
// of visited commits.
func FirstParentList(r *gogit.Repository, c *object.Commit) ([]*object.Commit, error) {
l := []*object.Commit{}
for {
if c == nil {
break
}

for c != nil {
l = append(l, c)

// continue with first parent if there is one
Expand Down
Loading