feat: migrate golangci-lint from v1 to v2 (#144)

Migrate golangci-lint from v1 to v2.

## Motivation and Context
The golangci-lint has been upgraded to v2 since March 2025.
The v2 of golangci-lint has simplified the linters management.

## How Has This Been Tested?
Tested locally with golangci-lint@v2.1.6

## Breaking Changes
No.

## Types of changes
- [ ] Bug fix (non-breaking change which fixes an issue)
- [x] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing
functionality to change)
- [ ] Documentation update

## Checklist
<!-- Go over all the following points, and put an `x` in all the boxes
that apply. -->
- [x] I have read the [MCP
Documentation](https://modelcontextprotocol.io)
- [x] My code follows the repository's style guidelines
- [x] New and existing tests pass locally
- [x] I have added appropriate error handling
- [ ] I have added or updated documentation as needed

## Additional context
<!-- Add any other context, implementation notes, or design decisions
-->

---------

Co-authored-by: haokunt <haokunt@opera.com>
Co-authored-by: Avinash Sridhar <sridharavinash@users.noreply.github.com>
Co-authored-by: Adam Jones <adamj+git@anthropic.com>
This commit is contained in:
Haokun Tang 2025-08-06 19:07:16 +08:00 • committed by GitHub
commit 6ba612942e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1,19 +1,11 @@
# GolangCI-Lint configuration
# See: https://golangci-lint.run/usage/configuration/
version: "2"
run:
timeout: 5m
modules-download-mode: readonly
linters:
enable:
- errcheck
- gosimple
- govet
- ineffassign
- staticcheck
- typecheck
- unused
- asasalint
- asciicheck
- bidichk
@ -28,14 +20,11 @@ linters:
- exhaustive
- forbidigo
- funlen
- gci
- gocognit
- goconst
- gocritic
- gocyclo
- godox
- gofmt
- goimports
- gomoddirectives
- gomodguard
- goprintffuncname
@ -59,8 +48,7 @@ linters:
- revive
- rowserrcheck
- sqlclosecheck
- stylecheck
- tenv
- staticcheck
- testpackage
- thelper
- tparallel
@ -69,55 +57,69 @@ linters:
- usestdlibvars
- wastedassign
- whitespace
linters-settings:
revive:
settings:
cyclop:
max-complexity: 50
funlen:
lines: 150
statements: 150
gocognit:
min-complexity: 50
goconst:
min-len: 3
min-occurrences: 3
gocyclo:
min-complexity: 25
lll:
line-length: 150
misspell:
locale: US
mnd:
checks:
- argument
- case
- condition
- operation
- return
nestif:
min-complexity: 8
exclusions:
generated: lax
presets:
- comments
- common-false-positives
- legacy
- std-error-handling
rules:
- name: use-any
disabled: false
severity: error
cyclop:
max-complexity: 50
funlen:
lines: 150
statements: 150
gocognit:
min-complexity: 50
gocyclo:
min-complexity: 25
goconst:
min-len: 3
min-occurrences: 3
mnd:
checks:
- argument
- case
- condition
- operation
- return
lll:
line-length: 150
misspell:
locale: US
nestif:
min-complexity: 8
issues:
exclude-rules:
# Exclude some linters from running on tests files.
- path: _test\.go
linters:
- mnd
- funlen
- gocyclo
- errcheck
- dupl
- gosec
# Ignore long lines in generated code
- path: docs/
linters:
- lll
# Allow local replacement directives in go.mod
- path: go\.mod
linters:
- gomoddirectives
- linters:
- dupl
- errcheck
- funlen
- gocyclo
- gosec
- mnd
path: _test\.go
- linters:
- lll
path: docs/
- linters:
- mnd
path: integrationtests/
- linters:
- gomoddirectives
path: go\.mod
paths:
- third_party$
- builtin$
- examples$
formatters:
enable:
- gci
- gofmt
- goimports
exclusions:
generated: lax
paths:
- third_party$
- builtin$
- examples$