mirror of
https://github.com/gomods/athens
synced 2026-02-03 11:00:32 +00:00
chore: bump golangci-lint to v2 (#2042)
This commit is contained in:
@@ -11,7 +11,7 @@ jobs:
|
||||
lint:
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
GOLANGCI_LINT_VERSION: v1.61.0
|
||||
GOLANGCI_LINT_VERSION: v2.0.2
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
@@ -21,7 +21,7 @@ jobs:
|
||||
go-version-file: 'go.mod'
|
||||
cache: true
|
||||
- name: Lint code
|
||||
uses: golangci/golangci-lint-action@v6
|
||||
uses: golangci/golangci-lint-action@v7
|
||||
with:
|
||||
version: ${{ env.GOLANGCI_LINT_VERSION }}
|
||||
|
||||
|
||||
+61
-61
@@ -1,86 +1,86 @@
|
||||
version: "2"
|
||||
run:
|
||||
tests: false
|
||||
timeout: 5m
|
||||
|
||||
linters-settings:
|
||||
cyclop:
|
||||
max-complexity: 12
|
||||
skip-tests: true
|
||||
errcheck:
|
||||
exclude-functions:
|
||||
- (*go.etcd.io/etcd/client/v3/concurrency.Mutex).Unlock
|
||||
- (*go.etcd.io/etcd/client/v3/concurrency.Session).Close
|
||||
gofumpt:
|
||||
extra-rules: true
|
||||
formatters:
|
||||
enable:
|
||||
- gci
|
||||
- gofmt
|
||||
- gofumpt
|
||||
- goimports
|
||||
settings:
|
||||
gofumpt:
|
||||
extra-rules: true
|
||||
exclusions:
|
||||
generated: lax
|
||||
|
||||
linters:
|
||||
enable-all: true
|
||||
default: all
|
||||
disable:
|
||||
- perfsprint # new
|
||||
- testifylint # new
|
||||
- spancheck # new
|
||||
- rowserrcheck # new
|
||||
- mnd # new
|
||||
- intrange # new
|
||||
- depguard # new
|
||||
- revive # new
|
||||
- errcheck # new
|
||||
- cyclop
|
||||
- depguard
|
||||
- err113
|
||||
- errcheck
|
||||
- errchkjson
|
||||
- exhaustive
|
||||
- exhaustruct
|
||||
- execinquery # deprecated
|
||||
- exportloopref # deprecated
|
||||
- forbidigo
|
||||
- forcetypeassert
|
||||
- funlen
|
||||
- gochecknoglobals
|
||||
- gochecknoinits
|
||||
- gocognit
|
||||
- goconst
|
||||
- godox
|
||||
- err113
|
||||
- gomnd
|
||||
- intrange
|
||||
- ireturn
|
||||
- lll
|
||||
- mnd
|
||||
- musttag
|
||||
- nilnil
|
||||
- nlreturn
|
||||
- nonamedreturns
|
||||
- perfsprint
|
||||
- recvcheck
|
||||
- revive
|
||||
- rowserrcheck
|
||||
- spancheck
|
||||
- tagliatelle
|
||||
- testifylint
|
||||
- varnamelen
|
||||
- wrapcheck
|
||||
- wsl
|
||||
- cyclop # TODO: turn this back on later
|
||||
- gocognit # TODO: turn this back on later
|
||||
- forbidigo # TODO: turn this back on later
|
||||
|
||||
issues:
|
||||
exclude-use-default: false
|
||||
exclude:
|
||||
- "package-comments: should have a package comment"
|
||||
- "ST1000: at least one file in a package should have a package comment"
|
||||
- "G204: Subprocess launched with a potential tainted input or cmd arguments"
|
||||
- "G204: Subprocess launched with variable"
|
||||
- "G402: TLS MinVersion too low."
|
||||
- "const `op` is unused"
|
||||
- "G115: integer overflow conversion int -> int32"
|
||||
exclude-rules:
|
||||
- path: cmd/proxy/main.go
|
||||
text: "G108: Profiling endpoint is automatically exposed on /debug/pprof"
|
||||
- path: pkg/stash/stasher.go
|
||||
linters:
|
||||
- contextcheck
|
||||
- path: pkg/stash/with_azureblob.go # False positive
|
||||
linters:
|
||||
- bodyclose
|
||||
- path: pkg/storage/azureblob/azureblob.go # False positive
|
||||
linters:
|
||||
- bodyclose
|
||||
- path: pkg/storage/compliance/*
|
||||
linters:
|
||||
- thelper
|
||||
- gosec
|
||||
- errcheck
|
||||
- path: pkg/index/compliance/*
|
||||
linters:
|
||||
- thelper
|
||||
- gosec
|
||||
- errcheck
|
||||
settings:
|
||||
cyclop:
|
||||
max-complexity: 12
|
||||
gosec:
|
||||
excludes:
|
||||
- G204
|
||||
- G402
|
||||
exclusions:
|
||||
generated: lax
|
||||
rules:
|
||||
- path: cmd/proxy/main.go
|
||||
text: 'G108: Profiling endpoint is automatically exposed on /debug/pprof'
|
||||
- linters:
|
||||
- contextcheck
|
||||
path: pkg/stash/stasher.go
|
||||
- linters:
|
||||
- bodyclose
|
||||
path: pkg/stash/with_azureblob.go
|
||||
- linters:
|
||||
- bodyclose
|
||||
path: pkg/storage/azureblob/azureblob.go
|
||||
- linters:
|
||||
- gosec
|
||||
- thelper
|
||||
path: pkg/storage/compliance/*
|
||||
- linters:
|
||||
- thelper
|
||||
path: pkg/index/compliance/*
|
||||
- path: (.+)\.go$
|
||||
text: 'package-comments: should have a package comment'
|
||||
- path: (.+)\.go$
|
||||
text: 'ST1000: at least one file in a package should have a package comment'
|
||||
- path: (.+)\.go$
|
||||
text: 'G115: integer overflow conversion int -> int32'
|
||||
|
||||
@@ -100,7 +100,6 @@ func (el *EnvList) Add(key, value string) {
|
||||
// See the below link for more information:
|
||||
// https://github.com/gomods/athens/issues/1404
|
||||
func (el *EnvList) Decode(value string) error {
|
||||
const op errors.Op = "envList.Decode"
|
||||
if value == "" {
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ type indexer struct {
|
||||
lines []*index.Line
|
||||
}
|
||||
|
||||
func (i *indexer) Index(ctx context.Context, mod, ver string) error {
|
||||
func (i *indexer) Index(_ context.Context, mod, ver string) error {
|
||||
const op errors.Op = "mem.Index"
|
||||
i.mu.Lock()
|
||||
defer i.mu.Unlock()
|
||||
@@ -37,8 +37,7 @@ func (i *indexer) Index(ctx context.Context, mod, ver string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (i *indexer) Lines(ctx context.Context, since time.Time, limit int) ([]*index.Line, error) {
|
||||
const op errors.Op = "mem.Lines"
|
||||
func (i *indexer) Lines(_ context.Context, since time.Time, limit int) ([]*index.Line, error) {
|
||||
lines := []*index.Line{}
|
||||
var count int
|
||||
i.mu.RLock()
|
||||
|
||||
@@ -5,7 +5,6 @@ import (
|
||||
"net/url"
|
||||
"strings"
|
||||
|
||||
"github.com/gomods/athens/pkg/errors"
|
||||
"github.com/gomods/athens/pkg/module"
|
||||
"github.com/gomods/athens/pkg/paths"
|
||||
"github.com/gorilla/mux"
|
||||
@@ -14,7 +13,6 @@ import (
|
||||
// NewFilterMiddleware builds a middleware function that implements the
|
||||
// filters configured in the filter file.
|
||||
func NewFilterMiddleware(mf *module.Filter, upstreamEndpoint string) mux.MiddlewareFunc {
|
||||
const op errors.Op = "actions.NewFilterMiddleware"
|
||||
return func(h http.Handler) http.Handler {
|
||||
f := func(w http.ResponseWriter, r *http.Request) {
|
||||
mod, err := paths.GetModule(r)
|
||||
|
||||
@@ -16,7 +16,6 @@ import (
|
||||
// NewValidationMiddleware builds a middleware function that performs validation checks by calling
|
||||
// an external webhook.
|
||||
func NewValidationMiddleware(client *http.Client, validatorHook string) mux.MiddlewareFunc {
|
||||
const op errors.Op = "actions.NewValidationMiddleware"
|
||||
return func(h http.Handler) http.Handler {
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
mod, err := paths.GetModule(r)
|
||||
|
||||
@@ -26,7 +26,6 @@ type checker struct {
|
||||
}
|
||||
|
||||
func (c *checker) Exists(ctx context.Context, module, version string) (bool, error) {
|
||||
const op errors.Op = "checker.Exists"
|
||||
_, err := c.strg.Info(ctx, module, version)
|
||||
if err != nil {
|
||||
if errors.Is(err, errors.KindNotFound) {
|
||||
|
||||
@@ -156,8 +156,8 @@ func (s *Storage) upload(ctx context.Context, path string, stream io.Reader, fir
|
||||
// We set this metadata only for the first of the three files uploaded,
|
||||
// for use as a singleflight lock.
|
||||
if first {
|
||||
wc.ObjectAttrs.Metadata = make(map[string]string)
|
||||
wc.ObjectAttrs.Metadata["in_progress"] = "true"
|
||||
wc.Metadata = make(map[string]string)
|
||||
wc.Metadata["in_progress"] = "true"
|
||||
}
|
||||
|
||||
// NOTE: content type is auto detected on GCP side and ACL defaults to public
|
||||
|
||||
Reference in New Issue
Block a user