golangci-lint: update to v2

Signed-off-by: Nicola Murino <nicola.murino@gmail.com>
This commit is contained in:
Nicola Murino
2025-04-12 23:09:27 +02:00
parent b0c512d4a1
commit 302a7fafc3
5 changed files with 53 additions and 47 deletions

View File

@@ -614,7 +614,7 @@ jobs:
go-version: '1.24'
- uses: actions/checkout@v4
- name: Run golangci-lint
uses: golangci/golangci-lint-action@v6
uses: golangci/golangci-lint-action@v7
with:
args: --timeout=10m
version: latest

View File

@@ -1,52 +1,57 @@
version: "2"
run:
timeout: 10m
issues-exit-code: 1
tests: true
linters-settings:
dupl:
threshold: 150
errcheck:
check-type-assertions: false
check-blank: false
goconst:
min-len: 3
min-occurrences: 3
gocyclo:
min-complexity: 15
gofmt:
simplify: true
goimports:
local-prefixes: github.com/drakkan/sftpgo
#govet:
# report about shadowed variables
#check-shadowing: true
#enable:
# - fieldalignment
issues:
include:
- EXC0002
- EXC0012
- EXC0013
- EXC0014
- EXC0015
linters:
enable:
- goconst
- errcheck
- gofmt
- goimports
- revive
- unconvert
- unparam
- bodyclose
- dogsled
- dupl
- goconst
- gocyclo
- misspell
- whitespace
- dupl
- revive
- rowserrcheck
- dogsled
- govet
- unconvert
- unparam
- whitespace
settings:
dupl:
threshold: 150
errcheck:
check-type-assertions: false
check-blank: false
goconst:
min-len: 3
min-occurrences: 3
gocyclo:
min-complexity: 15
staticcheck:
checks:
["all", "-QF1003", "-ST1003", "-QF1008", "-QF1006", "-QF1007", "-QF1001", "-ST1020"]
exclusions:
generated: lax
presets:
- common-false-positives
- legacy
- std-error-handling
paths:
- third_party$
- builtin$
- examples$
formatters:
enable:
- gofmt
- goimports
settings:
gofmt:
simplify: true
goimports:
local-prefixes:
- github.com/drakkan/sftpgo
exclusions:
generated: lax
paths:
- third_party$
- builtin$
- examples$

View File

@@ -35,7 +35,7 @@ var (
)
// BaseTransfer contains protocols common transfer details for an upload or a download.
type BaseTransfer struct { //nolint:maligned
type BaseTransfer struct {
ID int64
BytesSent atomic.Int64
BytesReceived atomic.Int64

View File

@@ -29,6 +29,7 @@ import (
"time"
bolt "go.etcd.io/bbolt"
bolterrors "go.etcd.io/bbolt/errors"
"github.com/drakkan/sftpgo/v2/internal/logger"
"github.com/drakkan/sftpgo/v2/internal/util"
@@ -3177,7 +3178,7 @@ func (p *BoltProvider) resetDatabase() error {
return p.dbHandle.Update(func(tx *bolt.Tx) error {
for _, bucketName := range boltBuckets {
err := tx.DeleteBucket(bucketName)
if err != nil && !errors.Is(err, bolt.ErrBucketNotFound) {
if err != nil && !errors.Is(err, bolterrors.ErrBucketNotFound) {
return fmt.Errorf("unable to remove bucket %v: %w", bucketName, err)
}
}

View File

@@ -256,7 +256,7 @@ func ParseBytes(s string) (int64, error) {
num := s[:lastDigit]
if hasComma {
num = strings.Replace(num, ",", "", -1)
num = strings.ReplaceAll(num, ",", "")
}
f, err := strconv.ParseFloat(num, 64)