diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml index b94db91..d4c870c 100644 --- a/.github/workflows/golangci-lint.yml +++ b/.github/workflows/golangci-lint.yml @@ -5,8 +5,6 @@ on: branches: - '**' pull_request: - branches: - - master permissions: contents: read @@ -29,6 +27,6 @@ jobs: go-version: ${{ env.GO_VERSION }} - name: Run golangci-lint - uses: golangci/golangci-lint-action@v6 + uses: golangci/golangci-lint-action@v7 with: - version: v1.60.3 + version: v2.1.5 diff --git a/.golangci.yml b/.golangci.yml index ea52710..f0efac3 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,22 +1,18 @@ +version: "2" run: timeout: 2m - linters: - disable-all: true + default: none enable: - dupl - errcheck - errname - errorlint - funlen - - gci - goconst - gocritic - gocyclo - - gofmt - - goimports - gosec - - gosimple - govet - ineffassign - lll @@ -25,29 +21,45 @@ linters: - prealloc - revive - staticcheck - - stylecheck - thelper - tparallel - - typecheck - unconvert - unparam - unused - whitespace - -linters-settings: - gosec: - excludes: - - G115 - thelper: - test: - begin: false - -issues: - exclude-rules: - - path: _test\.go - linters: - - errcheck - - funlen - - exclude-dirs: - - benchmarks + settings: + gosec: + excludes: + - G115 + thelper: + test: + begin: false + exclusions: + generated: lax + presets: + - comments + - common-false-positives + - legacy + - std-error-handling + rules: + - linters: + - errcheck + - funlen + path: _test\.go + paths: + - benchmarks + - third_party$ + - builtin$ + - examples$ +formatters: + enable: + - gci + - gofmt + - goimports + exclusions: + generated: lax + paths: + - benchmarks + - third_party$ + - builtin$ + - examples$ diff --git a/map_concurrent.go b/map_concurrent.go index 3c22f50..d939329 100644 --- a/map_concurrent.go +++ b/map_concurrent.go @@ -136,6 +136,7 @@ func (cm *ConcurrentMap[K, V]) Values() []*V { return values } +//nolint:staticcheck func (cm *ConcurrentMap[K, V]) smap() *sync.Map { for { if !cm.clearing.Load() { diff --git a/map_sharded.go b/map_sharded.go index 25e5ffe..275e92a 100644 --- a/map_sharded.go +++ b/map_sharded.go @@ -24,7 +24,7 @@ var _ Map[int, any] = (*ShardedMap[int, any])(nil) func NewShardedMap[K comparable, V any](shards int) *ShardedMap[K, V] { return NewShardedMapWithHash[K, V](shards, func(key K) uint64 { h := fnv.New64a() - h.Write([]byte(fmt.Sprint(key))) + _, _ = fmt.Fprint(h, key) return h.Sum64() }) } diff --git a/value.go b/value.go index 1ef4595..bf10aad 100644 --- a/value.go +++ b/value.go @@ -14,7 +14,9 @@ type Value struct { // CompareAndSwap executes the compare-and-swap operation for the Value. // The current implementation is not atomic. -func (v *Value) CompareAndSwap(old any, new any) (swapped bool) { +// +//nolint:revive +func (v *Value) CompareAndSwap(old, new any) (swapped bool) { defer func() { if err := recover(); err != nil { swapped = false @@ -49,6 +51,8 @@ func (v *Value) Store(val any) { // Swap stores new into Value and returns the previous value. // It returns nil if the Value is empty. // Swap(nil) panics. +// +//nolint:revive func (v *Value) Swap(new any) (old any) { oldValue := v.p.Swap(initValue(new)) if oldValue != nil {