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' go-version: '1.24'
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- name: Run golangci-lint - name: Run golangci-lint
uses: golangci/golangci-lint-action@v6 uses: golangci/golangci-lint-action@v7
with: with:
args: --timeout=10m args: --timeout=10m
version: latest version: latest

View File

@@ -1,10 +1,21 @@
version: "2"
run: run:
timeout: 10m
issues-exit-code: 1 issues-exit-code: 1
tests: true tests: true
linters:
enable:
linters-settings: - bodyclose
- dogsled
- dupl
- goconst
- gocyclo
- misspell
- revive
- rowserrcheck
- unconvert
- unparam
- whitespace
settings:
dupl: dupl:
threshold: 150 threshold: 150
errcheck: errcheck:
@@ -15,38 +26,32 @@ linters-settings:
min-occurrences: 3 min-occurrences: 3
gocyclo: gocyclo:
min-complexity: 15 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: gofmt:
simplify: true simplify: true
goimports: goimports:
local-prefixes: github.com/drakkan/sftpgo local-prefixes:
#govet: - github.com/drakkan/sftpgo
# report about shadowed variables exclusions:
#check-shadowing: true generated: lax
#enable: paths:
# - fieldalignment - third_party$
- builtin$
issues: - examples$
include:
- EXC0002
- EXC0012
- EXC0013
- EXC0014
- EXC0015
linters:
enable:
- goconst
- errcheck
- gofmt
- goimports
- revive
- unconvert
- unparam
- bodyclose
- gocyclo
- misspell
- whitespace
- dupl
- rowserrcheck
- dogsled
- govet

View File

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

View File

@@ -29,6 +29,7 @@ import (
"time" "time"
bolt "go.etcd.io/bbolt" bolt "go.etcd.io/bbolt"
bolterrors "go.etcd.io/bbolt/errors"
"github.com/drakkan/sftpgo/v2/internal/logger" "github.com/drakkan/sftpgo/v2/internal/logger"
"github.com/drakkan/sftpgo/v2/internal/util" "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 { return p.dbHandle.Update(func(tx *bolt.Tx) error {
for _, bucketName := range boltBuckets { for _, bucketName := range boltBuckets {
err := tx.DeleteBucket(bucketName) 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) 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] num := s[:lastDigit]
if hasComma { if hasComma {
num = strings.Replace(num, ",", "", -1) num = strings.ReplaceAll(num, ",", "")
} }
f, err := strconv.ParseFloat(num, 64) f, err := strconv.ParseFloat(num, 64)