chore(ci): upgraded linter to 1.57.1 (#3753)

This commit is contained in:
Jarek Kowalski
2024-03-25 22:20:38 -07:00
committed by GitHub
parent b9a633faad
commit 7278f570e2
31 changed files with 25 additions and 63 deletions

View File

@@ -1,7 +1,3 @@
run:
skip-dirs:
- test/testdata_etc
linters-settings:
cyclop:
max-complexity: 20
@@ -58,7 +54,7 @@ linters-settings:
goimports:
local-prefixes: github.com/kopia/kopia
govet:
check-shadowing: true
shadow: true
lll:
line-length: 256
maligned:

View File

@@ -70,29 +70,29 @@ endif
lint: $(linter)
ifneq ($(GOOS)/$(GOARCH),linux/arm64)
ifneq ($(GOOS)/$(GOARCH),linux/arm)
$(linter) --deadline $(LINTER_DEADLINE) run $(linter_flags)
$(linter) --timeout $(LINTER_DEADLINE) run $(linter_flags)
endif
endif
lint-fix: $(linter)
ifneq ($(GOOS)/$(GOARCH),linux/arm64)
ifneq ($(GOOS)/$(GOARCH),linux/arm)
$(linter) --deadline $(LINTER_DEADLINE) run --fix $(linter_flags)
$(linter) --timeout $(LINTER_DEADLINE) run --fix $(linter_flags)
endif
endif
lint-and-log: $(linter)
$(linter) --deadline $(LINTER_DEADLINE) run $(linter_flags) | tee .linterr.txt
$(linter) --timeout $(LINTER_DEADLINE) run $(linter_flags) | tee .linterr.txt
lint-all: $(linter)
GOOS=windows GOARCH=amd64 $(linter) --deadline $(LINTER_DEADLINE) run $(linter_flags)
GOOS=linux GOARCH=amd64 $(linter) --deadline $(LINTER_DEADLINE) run $(linter_flags)
GOOS=linux GOARCH=arm64 $(linter) --deadline $(LINTER_DEADLINE) run $(linter_flags)
GOOS=linux GOARCH=arm $(linter) --deadline $(LINTER_DEADLINE) run $(linter_flags)
GOOS=darwin GOARCH=amd64 $(linter) --deadline $(LINTER_DEADLINE) run $(linter_flags)
GOOS=darwin GOARCH=arm64 $(linter) --deadline $(LINTER_DEADLINE) run $(linter_flags)
GOOS=openbsd GOARCH=amd64 $(linter) --deadline $(LINTER_DEADLINE) run $(linter_flags)
GOOS=freebsd GOARCH=amd64 $(linter) --deadline $(LINTER_DEADLINE) run $(linter_flags)
GOOS=windows GOARCH=amd64 $(linter) --timeout $(LINTER_DEADLINE) run $(linter_flags)
GOOS=linux GOARCH=amd64 $(linter) --timeout $(LINTER_DEADLINE) run $(linter_flags)
GOOS=linux GOARCH=arm64 $(linter) --timeout $(LINTER_DEADLINE) run $(linter_flags)
GOOS=linux GOARCH=arm $(linter) --timeout $(LINTER_DEADLINE) run $(linter_flags)
GOOS=darwin GOARCH=amd64 $(linter) --timeout $(LINTER_DEADLINE) run $(linter_flags)
GOOS=darwin GOARCH=arm64 $(linter) --timeout $(LINTER_DEADLINE) run $(linter_flags)
GOOS=openbsd GOARCH=amd64 $(linter) --timeout $(LINTER_DEADLINE) run $(linter_flags)
GOOS=freebsd GOARCH=amd64 $(linter) --timeout $(LINTER_DEADLINE) run $(linter_flags)
vet:
go vet -all .

View File

@@ -432,7 +432,6 @@ func assertDirectRepository(act func(ctx context.Context, rep repo.DirectReposit
func (c *App) directRepositoryWriteAction(act func(ctx context.Context, rep repo.DirectRepositoryWriter) error) func(ctx *kingpin.ParseContext) error {
return c.maybeRepositoryAction(assertDirectRepository(func(ctx context.Context, rep repo.DirectRepository) error {
//nolint:wrapcheck
return repo.DirectWriteSession(ctx, rep, repo.WriteSessionOptions{
Purpose: "cli:" + c.currentActionName(),
OnUpload: c.progress.UploadedBytes,
@@ -463,7 +462,6 @@ func (c *App) repositoryReaderAction(act func(ctx context.Context, rep repo.Repo
func (c *App) repositoryWriterAction(act func(ctx context.Context, rep repo.RepositoryWriter) error) func(ctx *kingpin.ParseContext) error {
return c.maybeRepositoryAction(func(ctx context.Context, rep repo.Repository) error {
//nolint:wrapcheck
return repo.WriteSession(ctx, rep, repo.WriteSessionOptions{
Purpose: "cli:" + c.currentActionName(),
OnUpload: c.progress.UploadedBytes,
@@ -578,7 +576,6 @@ func (c *App) maybeRunMaintenance(ctx context.Context, rep repo.Repository) erro
Purpose: "maybeRunMaintenance",
OnUpload: c.progress.UploadedBytes,
}, func(ctx context.Context, w repo.DirectRepositoryWriter) error {
//nolint:wrapcheck
return snapshotmaintenance.Run(ctx, w, maintenance.ModeAuto, false, maintenance.SafetyFull)
})

View File

@@ -53,7 +53,6 @@ func clearCacheDirectory(ctx context.Context, d string) error {
log(ctx).Infof("Clearing cache directory: %v.", d)
err := retry.WithExponentialBackoffNoValue(ctx, "delete cache", func() error {
//nolint:wrapcheck
return os.RemoveAll(d)
}, retry.Always)
if err != nil {

View File

@@ -43,7 +43,6 @@ func (c *commandCacheSync) run(ctx context.Context, rep repo.DirectRepositoryWri
eg.Go(func() error {
defer close(ch)
//nolint:wrapcheck
return rep.BlobReader().ListBlobs(ctx, content.PackBlobIDPrefixSpecial, func(bm blob.Metadata) error {
ch <- bm.BlobID

View File

@@ -88,7 +88,7 @@ func (c *commandPolicyEdit) run(ctx context.Context, rep repo.RepositoryWriter)
updated = &policy.Policy{}
d := json.NewDecoder(bytes.NewBufferString(edited))
d.DisallowUnknownFields()
//nolint:wrapcheck
return d.Decode(updated)
}); err != nil {
return errors.Wrap(err, "unable to launch editor")

View File

@@ -31,14 +31,12 @@ func (c *commandRepositoryConnect) setup(svc advancedAppServices, parent command
cc := cmd.Command(prov.Name, "Connect to repository in "+prov.Description)
f.Setup(svc, cc)
cc.Action(func(kpc *kingpin.ParseContext) error {
//nolint:wrapcheck
return svc.runAppWithContext(kpc.SelectedCommand, func(ctx context.Context) error {
st, err := f.Connect(ctx, false, 0)
if err != nil {
return errors.Wrap(err, "can't connect to storage")
}
//nolint:wrapcheck
return svc.runConnectCommandWithStorage(ctx, &c.co, st)
})
})

View File

@@ -62,7 +62,6 @@ func (c *commandRepositoryCreate) setup(svc advancedAppServices, parent commandP
cc := cmd.Command(prov.Name, "Create repository in "+prov.Description)
f.Setup(svc, cc)
cc.Action(func(kpc *kingpin.ParseContext) error {
//nolint:wrapcheck
return svc.runAppWithContext(kpc.SelectedCommand, func(ctx context.Context) error {
st, err := f.Connect(ctx, true, c.createFormatVersion)
if err != nil {

View File

@@ -30,7 +30,6 @@ func (c *commandRepositoryRepair) setup(svc advancedAppServices, parent commandP
cc := cmd.Command(prov.Name, "Repair repository in "+prov.Description)
f.Setup(svc, cc)
cc.Action(func(kpc *kingpin.ParseContext) error {
//nolint:wrapcheck
return svc.runAppWithContext(kpc.SelectedCommand, func(ctx context.Context) error {
st, err := f.Connect(ctx, false, 0)
if err != nil {

View File

@@ -54,7 +54,6 @@ func (c *commandRepositorySyncTo) setup(svc advancedAppServices, parent commandP
cc := cmd.Command(prov.Name, "Synchronize repository data to another repository in "+prov.Description)
f.Setup(svc, cc)
cc.Action(func(kpc *kingpin.ParseContext) error {
//nolint:wrapcheck
return svc.runAppWithContext(kpc.SelectedCommand, func(ctx context.Context) error {
st, err := f.Connect(ctx, false, 0)
if err != nil {

View File

@@ -165,7 +165,6 @@ func (c *commandServerStart) serverStartOptions(ctx context.Context) (*server.Op
func (c *commandServerStart) initRepositoryPossiblyAsync(ctx context.Context, srv *server.Server) error {
initialize := func(ctx context.Context) (repo.Repository, error) {
//nolint:wrapcheck
return c.svc.openRepository(ctx, false)
}

View File

@@ -24,7 +24,7 @@ func init() {
return nil, errors.Errorf("required salt size is atleast %d bytes", minPbkdfSha256SaltSize)
}
//nolint:wrapcheck,gomnd
//nolint:gomnd
return scrypt.Key([]byte(password), salt, 65536, 8, 1, MasterKeyLength)
})
}

View File

@@ -69,7 +69,6 @@ func (v *Queue) Process(ctx context.Context, workers int) error {
select {
case <-ctx.Done():
// context canceled - some other worker returned an error.
//nolint:wrapcheck
return ctx.Err()
default:

View File

@@ -140,7 +140,6 @@ func handleEstimate(ctx context.Context, rc requestContext) (interface{}, *apiEr
ctrl.OnCancel(cancel)
//nolint:wrapcheck
return snapshotfs.Estimate(estimatectx, dir, policyTree, estimateTaskProgress{ctrl}, req.MaxExamplesPerBucket)
})

View File

@@ -75,7 +75,6 @@ func handleSourcesCreate(ctx context.Context, rc requestContext) (interface{}, *
if err = repo.WriteSession(ctx, rc.rep, repo.WriteSessionOptions{
Purpose: "handleSourcesCreate",
}, func(ctx context.Context, w repo.RepositoryWriter) error {
//nolint:wrapcheck
return policy.SetPolicy(ctx, w, sourceInfo, req.Policy)
}); err != nil {
return nil, internalServerError(errors.Wrap(err, "unable to set initial policy"))

View File

@@ -934,7 +934,6 @@ func RetryInitRepository(initialize InitRepositoryFunc) InitRepositoryFunc {
log(ctx).Warnf("unable to open repository: %v, will keep trying until canceled. Sleeping for %v", rerr, nextSleepTime)
if !clock.SleepInterruptibly(ctx, nextSleepTime) {
//nolint:wrapcheck
return nil, ctx.Err()
}
@@ -964,11 +963,9 @@ func(ctx context.Context, ctrl uitask.Controller) error {
func (s *Server) runMaintenanceTask(ctx context.Context, dr repo.DirectRepository) error {
return errors.Wrap(s.taskmgr.Run(ctx, "Maintenance", "Periodic maintenance", func(ctx context.Context, _ uitask.Controller) error {
//nolint:wrapcheck
return repo.DirectWriteSession(ctx, dr, repo.WriteSessionOptions{
Purpose: "periodicMaintenance",
}, func(ctx context.Context, w repo.DirectRepositoryWriter) error {
//nolint:wrapcheck
return snapshotmaintenance.Run(ctx, w, maintenance.ModeAuto, false, maintenance.SafetyFull)
})
}), "unable to run maintenance")

View File

@@ -61,7 +61,6 @@ func (s *b2Storage) GetBlob(ctx context.Context, id blob.ID, offset, length int6
return nil
}
//nolint:wrapcheck
return iocopy.JustCopy(output, r)
}

View File

@@ -92,7 +92,6 @@ func (fs *fsImpl) GetBlobFromPath(ctx context.Context, dirPath, path string, off
defer f.Close() //nolint:errcheck
if length < 0 {
//nolint:wrapcheck
return iocopy.JustCopy(output, f)
}

View File

@@ -50,7 +50,6 @@ func (gcs *gcsStorage) GetBlob(ctx context.Context, b blob.ID, offset, length in
}
defer reader.Close() //nolint:errcheck
//nolint:wrapcheck
return iocopy.JustCopy(output, reader)
}

View File

@@ -17,31 +17,26 @@ type retryingStorage struct {
}
func (s retryingStorage) GetBlob(ctx context.Context, id blob.ID, offset, length int64, output blob.OutputBuffer) error {
//nolint:wrapcheck
return retry.WithExponentialBackoffNoValue(ctx, fmt.Sprintf("GetBlob(%v,%v,%v)", id, offset, length), func() error {
output.Reset()
//nolint:wrapcheck
return s.Storage.GetBlob(ctx, id, offset, length, output)
}, isRetriable)
}
func (s retryingStorage) GetMetadata(ctx context.Context, id blob.ID) (blob.Metadata, error) {
return retry.WithExponentialBackoff(ctx, "GetMetadata("+string(id)+")", func() (blob.Metadata, error) {
//nolint:wrapcheck
return s.Storage.GetMetadata(ctx, id)
}, isRetriable)
}
func (s retryingStorage) PutBlob(ctx context.Context, id blob.ID, data blob.Bytes, opts blob.PutOptions) error {
return retry.WithExponentialBackoffNoValue(ctx, "PutBlob("+string(id)+")", func() error {
//nolint:wrapcheck
return s.Storage.PutBlob(ctx, id, data, opts)
}, isRetriable)
}
func (s retryingStorage) DeleteBlob(ctx context.Context, id blob.ID) error {
//nolint:wrapcheck
return retry.WithExponentialBackoffNoValue(ctx, "DeleteBlob("+string(id)+")", func() error {
return s.Storage.DeleteBlob(ctx, id)
}, isRetriable)

View File

@@ -73,7 +73,6 @@ func (s *s3Storage) getBlobWithVersion(ctx context.Context, b blob.ID, version s
return nil
}
//nolint:wrapcheck
return iocopy.JustCopy(output, o)
}

View File

@@ -324,7 +324,6 @@ func (s *sftpImpl) DeleteBlobInPath(ctx context.Context, dirPath, fullPath strin
func (s *sftpImpl) ReadDir(ctx context.Context, dirname string) ([]os.FileInfo, error) {
return connection.UsingConnection(ctx, s.rec, "ReadDir", func(conn connection.Connection) ([]os.FileInfo, error) {
//nolint:wrapcheck
return sftpClientFromConnection(conn).ReadDir(dirname)
})
}

View File

@@ -164,19 +164,17 @@ func (d *davStorageImpl) PutBlobInPath(ctx context.Context, dirPath, filePath st
b := buf.Bytes()
//nolint:wrapcheck
if err := retry.WithExponentialBackoffNoValue(ctx, "WriteTemporaryFileAndCreateParentDirs", func() error {
mkdirAttempted := false
for {
//nolint:wrapcheck
err := d.translateError(d.cli.Write(writePath, b, defaultFilePerm))
if err == nil {
if d.Options.AtomicWrites {
return nil
}
//nolint:wrapcheck
return d.cli.Rename(writePath, filePath, true)
}
@@ -216,7 +214,6 @@ func (d *davStorageImpl) DeleteBlobInPath(ctx context.Context, dirPath, filePath
_ = dirPath
err := d.translateError(retry.WithExponentialBackoffNoValue(ctx, "DeleteBlobInPath", func() error {
//nolint:wrapcheck
return d.cli.Remove(filePath)
}, isRetriable))
if errors.Is(err, blob.ErrBlobNotFound) {

View File

@@ -33,7 +33,6 @@ func (m *EncryptionManager) GetEncryptedBlob(ctx context.Context, blobID blob.ID
defer payload.Close()
if err := m.indexBlobCache.GetOrLoad(ctx, string(blobID), func(output *gather.WriteBuffer) error {
//nolint:wrapcheck
return m.st.GetBlob(ctx, blobID, 0, -1, output)
}, &payload); err != nil {
return errors.Wrap(err, "getContent")

View File

@@ -114,7 +114,7 @@ func NewFormattingOptionsProvider(f0 *ContentFormat, formatBytes []byte) (Provid
}
if f.GetECCAlgorithm() != "" && f.GetECCOverheadPercent() > 0 {
eccEncryptor, err := ecc.CreateEncryptor(f) //nolint:govet
eccEncryptor, err := ecc.CreateEncryptor(f)
if err != nil {
return nil, errors.Wrap(err, "unable to create ECC")
}

View File

@@ -13,7 +13,6 @@ func runTaskIndexCompactionQuick(ctx context.Context, runParams RunParameters, s
const maxSmallBlobsForIndexCompaction = 8
//nolint:wrapcheck
return runParams.rep.ContentManager().CompactIndexes(ctx, indexblob.CompactOptions{
MaxSmallBlobs: maxSmallBlobsForIndexCompaction,
DisableEventualConsistencySafety: safety.DisableEventualConsistencySafety,

View File

@@ -294,7 +294,6 @@ func openWithConfig(ctx context.Context, st blob.Storage, cliOpts ClientOptions,
}
_, err = retry.WithExponentialBackoffMaxRetries(ctx, -1, "wait for upgrade", func() (interface{}, error) {
//nolint:govet
uli, err := fmgr.UpgradeLockIntent(ctx)
if err != nil {
//nolint:wrapcheck

View File

@@ -41,7 +41,7 @@ func getStreamCopier(ctx context.Context, targetpath string, sparse bool) (strea
}
return func(w io.WriteSeeker, r io.Reader) (int64, error) {
return sparsefile.Copy(w, r, s) //nolint:wrapcheck
return sparsefile.Copy(w, r, s)
}, nil
}
@@ -50,7 +50,7 @@ func getStreamCopier(ctx context.Context, targetpath string, sparse bool) (strea
// Wrap iocopy.Copy to conform to StreamCopier type.
return func(w io.WriteSeeker, r io.Reader) (int64, error) {
return iocopy.Copy(w, r) //nolint:wrapcheck
return iocopy.Copy(w, r)
}, nil
}

View File

@@ -249,7 +249,6 @@ func (u *Uploader) uploadFileData(ctx context.Context, parentCheckpointRegistry
defer writer.Close() //nolint:errcheck
parentCheckpointRegistry.addCheckpointCallback(fname, func() (*snapshot.DirEntry, error) {
//nolint:govet
checkpointID, err := writer.Checkpoint()
if err != nil {
return nil, errors.Wrap(err, "checkpoint error")

View File

@@ -7,12 +7,12 @@ https://github.com/git-chglog/git-chglog/releases/download/v0.15.1/git-chglog_0.
https://github.com/gohugoio/hugo/releases/download/v0.113.0/hugo_extended_0.113.0_darwin-universal.tar.gz: 1557f896f34743d241e1aecab588be273dde59692b362a9f4488231a2595b2ae
https://github.com/gohugoio/hugo/releases/download/v0.113.0/hugo_extended_0.113.0_linux-amd64.tar.gz: e04bccfa81df6c727f1c03bc858eb21d6f95123d311cafe245f4485d289123f3
https://github.com/gohugoio/hugo/releases/download/v0.113.0/hugo_extended_0.113.0_windows-amd64.zip: 3eabfbfad1431939058e6f7e76573c6bac1fee92f3a7b1ac5739c555940f0e0e
https://github.com/golangci/golangci-lint/releases/download/v1.56.2/golangci-lint-1.56.2-darwin-amd64.tar.gz: 15c4d19a2c85a04f67779047dbb9467ba176c71fff762a0d514a21bb75e4b42c
https://github.com/golangci/golangci-lint/releases/download/v1.56.2/golangci-lint-1.56.2-darwin-arm64.tar.gz: 5f9ecda712c7ae08fbf872336fae3db866720e5865903d4c53903184b2a2c2dc
https://github.com/golangci/golangci-lint/releases/download/v1.56.2/golangci-lint-1.56.2-linux-amd64.tar.gz: e1c313fb5fc85a33890fdee5dbb1777d1f5829c84d655a47a55688f3aad5e501
https://github.com/golangci/golangci-lint/releases/download/v1.56.2/golangci-lint-1.56.2-linux-arm64.tar.gz: 0041594fde41ce43b75e65476a050fe9057881d8b5bccd472f18357e2ead3e04
https://github.com/golangci/golangci-lint/releases/download/v1.56.2/golangci-lint-1.56.2-linux-armv6.tar.gz: 4820c7b0a2832812bc243328c5046bc06cca71874ca31f0001e2f8f5effaa0d7
https://github.com/golangci/golangci-lint/releases/download/v1.56.2/golangci-lint-1.56.2-windows-amd64.zip: d02df32c581281ef46af62d4ab71da6e24b47ef3e93e7f05d719fada74440185
https://github.com/golangci/golangci-lint/releases/download/v1.57.1/golangci-lint-1.57.1-darwin-amd64.tar.gz: 7b6ce262d6b318822ad6ad866da31a7e0e8f8042ec2b1a34018488532d9beb50
https://github.com/golangci/golangci-lint/releases/download/v1.57.1/golangci-lint-1.57.1-darwin-arm64.tar.gz: 0099453f7f9edf7438c848d2f1cebfe8bd2fe8ef8817ba89c315127ccddddee4
https://github.com/golangci/golangci-lint/releases/download/v1.57.1/golangci-lint-1.57.1-linux-amd64.tar.gz: 7e148df10de55dcbda283b43b9ea1c2f2a38b6e96ba91a71ec02eefcf336efbe
https://github.com/golangci/golangci-lint/releases/download/v1.57.1/golangci-lint-1.57.1-linux-arm64.tar.gz: 55708f17c659d1b4589fe2b2f6c1d5528f5e3d9376d6e26d4ae266346d035d06
https://github.com/golangci/golangci-lint/releases/download/v1.57.1/golangci-lint-1.57.1-linux-armv6.tar.gz: 245bfa5e8c43bedb9fddfb0e32896f914d3e2b74db99e1c828192256e302d42c
https://github.com/golangci/golangci-lint/releases/download/v1.57.1/golangci-lint-1.57.1-windows-amd64.zip: 7383a7dc7498ad4d0500ff6e661e50236216089cf68460f665553b9484c41601
https://github.com/goreleaser/goreleaser/releases/download/v0.176.0/goreleaser_Darwin_arm64.tar.gz: 1f95e6561974f4766d8833438b646b06930563ca9867447ea03edb623d876c75
https://github.com/goreleaser/goreleaser/releases/download/v0.176.0/goreleaser_Darwin_x86_64.tar.gz: 17ecad881a50e32f033da5a200c8417d37cae70f09e925645452937998aca506
https://github.com/goreleaser/goreleaser/releases/download/v0.176.0/goreleaser_Linux_arm64.tar.gz: 8bf2a9b9e84498bfa239f2fe91b2d555642c87ab9d3f5d37f29e6e97116910a3

View File

@@ -102,7 +102,7 @@ retry:=
endif
# tool versions
GOLANGCI_LINT_VERSION=1.56.2
GOLANGCI_LINT_VERSION=1.57.1
CHECKLOCKS_VERSION=e8c1fff214d0ecf02cfe5aa9c62d11174130c339
NODE_VERSION=18.16.0
HUGO_VERSION=0.113.0