diff --git a/.github/workflows/development.yml b/.github/workflows/development.yml index 25dbd9a6..17be5a88 100644 --- a/.github/workflows/development.yml +++ b/.github/workflows/development.yml @@ -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 diff --git a/.golangci.yml b/.golangci.yml index ac545673..db756a0a 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -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$ diff --git a/internal/common/transfer.go b/internal/common/transfer.go index f4e78e30..72854393 100644 --- a/internal/common/transfer.go +++ b/internal/common/transfer.go @@ -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 diff --git a/internal/dataprovider/bolt.go b/internal/dataprovider/bolt.go index 53bf3234..51645244 100644 --- a/internal/dataprovider/bolt.go +++ b/internal/dataprovider/bolt.go @@ -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) } } diff --git a/internal/util/util.go b/internal/util/util.go index fc61c00d..6b843967 100644 --- a/internal/util/util.go +++ b/internal/util/util.go @@ -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)