From c0514dd8baa6460ea1d3cf70d58a1a421eedcea8 Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Sat, 10 Feb 2024 22:58:10 +0100 Subject: [PATCH] Fix linter errors (except for tests) --- .golangci.yml | 5 +++++ cmd/restic/cmd_backup.go | 2 +- cmd/restic/cmd_cache.go | 2 +- cmd/restic/cmd_check.go | 8 ++++---- cmd/restic/cmd_diff.go | 2 +- cmd/restic/cmd_generate.go | 2 +- cmd/restic/cmd_key_list.go | 2 +- cmd/restic/cmd_list.go | 4 ++-- cmd/restic/cmd_options.go | 2 +- cmd/restic/cmd_prune.go | 8 ++++---- cmd/restic/cmd_recover.go | 4 ++-- cmd/restic/cmd_repair_index.go | 6 +++--- cmd/restic/cmd_repair_snapshots.go | 2 +- cmd/restic/cmd_restore.go | 4 ++-- cmd/restic/cmd_rewrite.go | 2 +- cmd/restic/cmd_stats.go | 2 +- cmd/restic/cmd_unlock.go | 2 +- cmd/restic/cmd_version.go | 2 +- cmd/restic/main.go | 2 +- internal/archiver/archiver.go | 6 +++--- internal/archiver/scanner.go | 8 ++++---- internal/backend/mem/mem_backend.go | 2 +- internal/backend/rclone/backend.go | 2 +- internal/checker/checker.go | 2 +- internal/fs/fs_track.go | 2 +- internal/fuse/snapshots_dirstruct.go | 2 +- internal/index/index_parallel.go | 2 +- internal/repository/key.go | 2 +- internal/repository/repair_pack.go | 2 +- internal/repository/repository.go | 4 ++-- internal/restic/backend_find.go | 2 +- internal/restic/lock.go | 4 ++-- internal/restic/snapshot.go | 2 +- internal/restorer/restorer.go | 6 +++--- internal/ui/backup/progress.go | 2 +- internal/walker/rewriter.go | 4 ++-- 36 files changed, 61 insertions(+), 56 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index c08331401..7dc6a8e7f 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -54,3 +54,8 @@ issues: # staticcheck: there's no easy way to replace these packages - "SA1019: \"golang.org/x/crypto/poly1305\" is deprecated" - "SA1019: \"golang.org/x/crypto/openpgp\" is deprecated" + + exclude-rules: + # revive: ignore unused parameters in tests + - path: (_test\.go|testing\.go|backend/.*/tests\.go) + text: "unused-parameter:" \ No newline at end of file diff --git a/cmd/restic/cmd_backup.go b/cmd/restic/cmd_backup.go index be7a2aa3f..318d17796 100644 --- a/cmd/restic/cmd_backup.go +++ b/cmd/restic/cmd_backup.go @@ -42,7 +42,7 @@ Exit status is 0 if the command was successful. Exit status is 1 if there was a fatal error (no snapshot created). Exit status is 3 if some source data could not be read (incomplete snapshot created). `, - PreRun: func(cmd *cobra.Command, args []string) { + PreRun: func(_ *cobra.Command, _ []string) { if backupOptions.Host == "" { hostname, err := os.Hostname() if err != nil { diff --git a/cmd/restic/cmd_cache.go b/cmd/restic/cmd_cache.go index 4a10d1027..354cec288 100644 --- a/cmd/restic/cmd_cache.go +++ b/cmd/restic/cmd_cache.go @@ -28,7 +28,7 @@ EXIT STATUS Exit status is 0 if the command was successful, and non-zero if there was any error. `, DisableAutoGenTag: true, - RunE: func(cmd *cobra.Command, args []string) error { + RunE: func(_ *cobra.Command, args []string) error { return runCache(cacheOptions, globalOptions, args) }, } diff --git a/cmd/restic/cmd_check.go b/cmd/restic/cmd_check.go index f04a4fe71..22f462d75 100644 --- a/cmd/restic/cmd_check.go +++ b/cmd/restic/cmd_check.go @@ -38,7 +38,7 @@ Exit status is 0 if the command was successful, and non-zero if there was any er RunE: func(cmd *cobra.Command, args []string) error { return runCheck(cmd.Context(), checkOptions, globalOptions, args) }, - PreRunE: func(cmd *cobra.Command, args []string) error { + PreRunE: func(_ *cobra.Command, _ []string) error { return checkFlags(checkOptions) }, } @@ -345,11 +345,11 @@ func runCheck(ctx context.Context, opts CheckOptions, gopts GlobalOptions, args if len(salvagePacks) > 0 { Warnf("\nThe repository contains pack files with damaged blobs. These blobs must be removed to repair the repository. This can be done using the following commands:\n\n") - var strIds []string + var strIDs []string for _, id := range salvagePacks { - strIds = append(strIds, id.String()) + strIDs = append(strIDs, id.String()) } - Warnf("RESTIC_FEATURES=repair-packs-v1 restic repair packs %v\nrestic repair snapshots --forget\n\n", strings.Join(strIds, " ")) + Warnf("RESTIC_FEATURES=repair-packs-v1 restic repair packs %v\nrestic repair snapshots --forget\n\n", strings.Join(strIDs, " ")) Warnf("Corrupted blobs are either caused by hardware problems or bugs in restic. Please open an issue at https://github.com/restic/restic/issues/new/choose for further troubleshooting!\n") } } diff --git a/cmd/restic/cmd_diff.go b/cmd/restic/cmd_diff.go index 06f2be2ae..3bd29fa67 100644 --- a/cmd/restic/cmd_diff.go +++ b/cmd/restic/cmd_diff.go @@ -418,7 +418,7 @@ func runDiff(ctx context.Context, opts DiffOptions, gopts GlobalOptions, args [] } if gopts.Quiet { - c.printChange = func(change *Change) {} + c.printChange = func(_ *Change) {} } stats := &DiffStatsContainer{ diff --git a/cmd/restic/cmd_generate.go b/cmd/restic/cmd_generate.go index 9d1652e93..ba710e708 100644 --- a/cmd/restic/cmd_generate.go +++ b/cmd/restic/cmd_generate.go @@ -21,7 +21,7 @@ EXIT STATUS Exit status is 0 if the command was successful, and non-zero if there was any error. `, DisableAutoGenTag: true, - RunE: func(cmd *cobra.Command, args []string) error { + RunE: func(_ *cobra.Command, args []string) error { return runGenerate(genOpts, args) }, } diff --git a/cmd/restic/cmd_key_list.go b/cmd/restic/cmd_key_list.go index 517b7c84b..2b3574281 100644 --- a/cmd/restic/cmd_key_list.go +++ b/cmd/restic/cmd_key_list.go @@ -69,7 +69,7 @@ func listKeys(ctx context.Context, s *repository.Repository, gopts GlobalOptions var m sync.Mutex var keys []keyInfo - err := restic.ParallelList(ctx, s, restic.KeyFile, s.Connections(), func(ctx context.Context, id restic.ID, size int64) error { + err := restic.ParallelList(ctx, s, restic.KeyFile, s.Connections(), func(ctx context.Context, id restic.ID, _ int64) error { k, err := repository.LoadKey(ctx, s, id) if err != nil { Warnf("LoadKey() failed: %v\n", err) diff --git a/cmd/restic/cmd_list.go b/cmd/restic/cmd_list.go index 8be99234f..becad7f0d 100644 --- a/cmd/restic/cmd_list.go +++ b/cmd/restic/cmd_list.go @@ -63,7 +63,7 @@ func runList(ctx context.Context, gopts GlobalOptions, args []string) error { case "locks": t = restic.LockFile case "blobs": - return index.ForAllIndexes(ctx, repo, repo, func(id restic.ID, idx *index.Index, oldFormat bool, err error) error { + return index.ForAllIndexes(ctx, repo, repo, func(_ restic.ID, idx *index.Index, _ bool, err error) error { if err != nil { return err } @@ -76,7 +76,7 @@ func runList(ctx context.Context, gopts GlobalOptions, args []string) error { return errors.Fatal("invalid type") } - return repo.List(ctx, t, func(id restic.ID, size int64) error { + return repo.List(ctx, t, func(id restic.ID, _ int64) error { Printf("%s\n", id) return nil }) diff --git a/cmd/restic/cmd_options.go b/cmd/restic/cmd_options.go index 471319dfb..85e062220 100644 --- a/cmd/restic/cmd_options.go +++ b/cmd/restic/cmd_options.go @@ -21,7 +21,7 @@ Exit status is 0 if the command was successful, and non-zero if there was any er `, Hidden: true, DisableAutoGenTag: true, - Run: func(cmd *cobra.Command, args []string) { + Run: func(_ *cobra.Command, _ []string) { fmt.Printf("All Extended Options:\n") var maxLen int for _, opt := range options.List() { diff --git a/cmd/restic/cmd_prune.go b/cmd/restic/cmd_prune.go index efd8f6e3a..1b9352ea7 100644 --- a/cmd/restic/cmd_prune.go +++ b/cmd/restic/cmd_prune.go @@ -37,7 +37,7 @@ EXIT STATUS Exit status is 0 if the command was successful, and non-zero if there was any error. `, DisableAutoGenTag: true, - RunE: func(cmd *cobra.Command, args []string) error { + RunE: func(cmd *cobra.Command, _ []string) error { return runPrune(cmd.Context(), pruneOptions, globalOptions) }, } @@ -101,7 +101,7 @@ func verifyPruneOptions(opts *PruneOptions) error { // parse MaxUnused either as unlimited, a percentage, or an absolute number of bytes switch { case maxUnused == "unlimited": - opts.maxUnusedBytes = func(used uint64) uint64 { + opts.maxUnusedBytes = func(_ uint64) uint64 { return math.MaxUint64 } @@ -130,7 +130,7 @@ func verifyPruneOptions(opts *PruneOptions) error { return errors.Fatalf("invalid number of bytes %q for --max-unused: %v", opts.MaxUnused, err) } - opts.maxUnusedBytes = func(used uint64) uint64 { + opts.maxUnusedBytes = func(_ uint64) uint64 { return uint64(size) } } @@ -798,7 +798,7 @@ func rebuildIndexFiles(ctx context.Context, gopts GlobalOptions, repo restic.Rep DeleteProgress: func() *progress.Counter { return newProgressMax(!gopts.Quiet, 0, "old indexes deleted") }, - DeleteReport: func(id restic.ID, err error) { + DeleteReport: func(id restic.ID, _ error) { if gopts.verbosity > 2 { Verbosef("removed index %v\n", id.String()) } diff --git a/cmd/restic/cmd_recover.go b/cmd/restic/cmd_recover.go index 499abdf80..b97a7582b 100644 --- a/cmd/restic/cmd_recover.go +++ b/cmd/restic/cmd_recover.go @@ -25,7 +25,7 @@ EXIT STATUS Exit status is 0 if the command was successful, and non-zero if there was any error. `, DisableAutoGenTag: true, - RunE: func(cmd *cobra.Command, args []string) error { + RunE: func(cmd *cobra.Command, _ []string) error { return runRecover(cmd.Context(), globalOptions) }, } @@ -91,7 +91,7 @@ func runRecover(ctx context.Context, gopts GlobalOptions) error { bar.Done() Verbosef("load snapshots\n") - err = restic.ForAllSnapshots(ctx, snapshotLister, repo, nil, func(id restic.ID, sn *restic.Snapshot, err error) error { + err = restic.ForAllSnapshots(ctx, snapshotLister, repo, nil, func(_ restic.ID, sn *restic.Snapshot, _ error) error { trees[*sn.Tree] = true return nil }) diff --git a/cmd/restic/cmd_repair_index.go b/cmd/restic/cmd_repair_index.go index fc5506b34..ea36f02f6 100644 --- a/cmd/restic/cmd_repair_index.go +++ b/cmd/restic/cmd_repair_index.go @@ -24,7 +24,7 @@ EXIT STATUS Exit status is 0 if the command was successful, and non-zero if there was any error. `, DisableAutoGenTag: true, - RunE: func(cmd *cobra.Command, args []string) error { + RunE: func(cmd *cobra.Command, _ []string) error { return runRebuildIndex(cmd.Context(), repairIndexOptions, globalOptions) }, } @@ -78,7 +78,7 @@ func rebuildIndex(ctx context.Context, opts RepairIndexOptions, gopts GlobalOpti if opts.ReadAllPacks { // get list of old index files but start with empty index - err := repo.List(ctx, restic.IndexFile, func(id restic.ID, size int64) error { + err := repo.List(ctx, restic.IndexFile, func(id restic.ID, _ int64) error { obsoleteIndexes = append(obsoleteIndexes, id) return nil }) @@ -88,7 +88,7 @@ func rebuildIndex(ctx context.Context, opts RepairIndexOptions, gopts GlobalOpti } else { Verbosef("loading indexes...\n") mi := index.NewMasterIndex() - err := index.ForAllIndexes(ctx, repo, repo, func(id restic.ID, idx *index.Index, oldFormat bool, err error) error { + err := index.ForAllIndexes(ctx, repo, repo, func(id restic.ID, idx *index.Index, _ bool, err error) error { if err != nil { Warnf("removing invalid index %v: %v\n", id, err) obsoleteIndexes = append(obsoleteIndexes, id) diff --git a/cmd/restic/cmd_repair_snapshots.go b/cmd/restic/cmd_repair_snapshots.go index 19e457b1f..cc3d0eb85 100644 --- a/cmd/restic/cmd_repair_snapshots.go +++ b/cmd/restic/cmd_repair_snapshots.go @@ -125,7 +125,7 @@ func runRepairSnapshots(ctx context.Context, gopts GlobalOptions, opts RepairOpt node.Size = newSize return node }, - RewriteFailedTree: func(nodeID restic.ID, path string, _ error) (restic.ID, error) { + RewriteFailedTree: func(_ restic.ID, path string, _ error) (restic.ID, error) { if path == "/" { Verbosef(" dir %q: not readable\n", path) // remove snapshots with invalid root node diff --git a/cmd/restic/cmd_restore.go b/cmd/restic/cmd_restore.go index 1208d30eb..37d304672 100644 --- a/cmd/restic/cmd_restore.go +++ b/cmd/restic/cmd_restore.go @@ -181,7 +181,7 @@ func runRestore(ctx context.Context, opts RestoreOptions, gopts GlobalOptions, excludePatterns := filter.ParsePatterns(opts.Exclude) insensitiveExcludePatterns := filter.ParsePatterns(opts.InsensitiveExclude) - selectExcludeFilter := func(item string, dstpath string, node *restic.Node) (selectedForRestore bool, childMayBeSelected bool) { + selectExcludeFilter := func(item string, _ string, node *restic.Node) (selectedForRestore bool, childMayBeSelected bool) { matched, err := filter.List(excludePatterns, item) if err != nil { msg.E("error for exclude pattern: %v", err) @@ -204,7 +204,7 @@ func runRestore(ctx context.Context, opts RestoreOptions, gopts GlobalOptions, includePatterns := filter.ParsePatterns(opts.Include) insensitiveIncludePatterns := filter.ParsePatterns(opts.InsensitiveInclude) - selectIncludeFilter := func(item string, dstpath string, node *restic.Node) (selectedForRestore bool, childMayBeSelected bool) { + selectIncludeFilter := func(item string, _ string, node *restic.Node) (selectedForRestore bool, childMayBeSelected bool) { matched, childMayMatch, err := filter.ListWithChild(includePatterns, item) if err != nil { msg.E("error for include pattern: %v", err) diff --git a/cmd/restic/cmd_rewrite.go b/cmd/restic/cmd_rewrite.go index 8dad492af..62624e75c 100644 --- a/cmd/restic/cmd_rewrite.go +++ b/cmd/restic/cmd_rewrite.go @@ -147,7 +147,7 @@ func rewriteSnapshot(ctx context.Context, repo *repository.Repository, sn *resti return rewriter.RewriteTree(ctx, repo, "/", *sn.Tree) } } else { - filter = func(ctx context.Context, sn *restic.Snapshot) (restic.ID, error) { + filter = func(_ context.Context, sn *restic.Snapshot) (restic.ID, error) { return *sn.Tree, nil } } diff --git a/cmd/restic/cmd_stats.go b/cmd/restic/cmd_stats.go index 1bece21d0..d3078a419 100644 --- a/cmd/restic/cmd_stats.go +++ b/cmd/restic/cmd_stats.go @@ -367,7 +367,7 @@ func statsDebug(ctx context.Context, repo restic.Repository) error { func statsDebugFileType(ctx context.Context, repo restic.Lister, tpe restic.FileType) (*sizeHistogram, error) { hist := newSizeHistogram(2 * repository.MaxPackSize) - err := repo.List(ctx, tpe, func(id restic.ID, size int64) error { + err := repo.List(ctx, tpe, func(_ restic.ID, size int64) error { hist.Add(uint64(size)) return nil }) diff --git a/cmd/restic/cmd_unlock.go b/cmd/restic/cmd_unlock.go index 7b449d949..6893f3365 100644 --- a/cmd/restic/cmd_unlock.go +++ b/cmd/restic/cmd_unlock.go @@ -19,7 +19,7 @@ EXIT STATUS Exit status is 0 if the command was successful, and non-zero if there was any error. `, DisableAutoGenTag: true, - RunE: func(cmd *cobra.Command, args []string) error { + RunE: func(cmd *cobra.Command, _ []string) error { return runUnlock(cmd.Context(), unlockOptions, globalOptions) }, } diff --git a/cmd/restic/cmd_version.go b/cmd/restic/cmd_version.go index 73469750f..e3f9b3010 100644 --- a/cmd/restic/cmd_version.go +++ b/cmd/restic/cmd_version.go @@ -21,7 +21,7 @@ EXIT STATUS Exit status is 0 if the command was successful, and non-zero if there was any error. `, DisableAutoGenTag: true, - Run: func(cmd *cobra.Command, args []string) { + Run: func(_ *cobra.Command, _ []string) { if globalOptions.JSON { type jsonVersion struct { Version string `json:"version"` diff --git a/cmd/restic/main.go b/cmd/restic/main.go index 4595e8161..b31ce1bb4 100644 --- a/cmd/restic/main.go +++ b/cmd/restic/main.go @@ -37,7 +37,7 @@ The full documentation can be found at https://restic.readthedocs.io/ . SilenceUsage: true, DisableAutoGenTag: true, - PersistentPreRunE: func(c *cobra.Command, args []string) error { + PersistentPreRunE: func(c *cobra.Command, _ []string) error { // set verbosity, default is one globalOptions.verbosity = 1 if globalOptions.Quiet && globalOptions.Verbose > 0 { diff --git a/internal/archiver/archiver.go b/internal/archiver/archiver.go index f2c481b32..77ddba7c4 100644 --- a/internal/archiver/archiver.go +++ b/internal/archiver/archiver.go @@ -147,8 +147,8 @@ func (o Options) ApplyDefaults() Options { func New(repo restic.Repository, fs fs.FS, opts Options) *Archiver { arch := &Archiver{ Repo: repo, - SelectByName: func(item string) bool { return true }, - Select: func(item string, fi os.FileInfo) bool { return true }, + SelectByName: func(_ string) bool { return true }, + Select: func(_ string, _ os.FileInfo) bool { return true }, FS: fs, Options: opts.ApplyDefaults(), @@ -762,7 +762,7 @@ func (arch *Archiver) Snapshot(ctx context.Context, targets []string, opts Snaps arch.runWorkers(wgCtx, wg) debug.Log("starting snapshot") - fn, nodeCount, err := arch.SaveTree(wgCtx, "/", atree, arch.loadParentTree(wgCtx, opts.ParentSnapshot), func(n *restic.Node, is ItemStats) { + fn, nodeCount, err := arch.SaveTree(wgCtx, "/", atree, arch.loadParentTree(wgCtx, opts.ParentSnapshot), func(_ *restic.Node, is ItemStats) { arch.CompleteItem("/", nil, nil, is, time.Since(start)) }) if err != nil { diff --git a/internal/archiver/scanner.go b/internal/archiver/scanner.go index 6ce2a4700..cc419b19e 100644 --- a/internal/archiver/scanner.go +++ b/internal/archiver/scanner.go @@ -25,10 +25,10 @@ type Scanner struct { func NewScanner(fs fs.FS) *Scanner { return &Scanner{ FS: fs, - SelectByName: func(item string) bool { return true }, - Select: func(item string, fi os.FileInfo) bool { return true }, - Error: func(item string, err error) error { return err }, - Result: func(item string, s ScanStats) {}, + SelectByName: func(_ string) bool { return true }, + Select: func(_ string, _ os.FileInfo) bool { return true }, + Error: func(_ string, err error) error { return err }, + Result: func(_ string, _ ScanStats) {}, } } diff --git a/internal/backend/mem/mem_backend.go b/internal/backend/mem/mem_backend.go index 2698a8275..eea5b060e 100644 --- a/internal/backend/mem/mem_backend.go +++ b/internal/backend/mem/mem_backend.go @@ -28,7 +28,7 @@ func NewFactory() location.Factory { return location.NewHTTPBackendFactory[struct{}, *MemoryBackend]( "mem", - func(s string) (*struct{}, error) { + func(_ string) (*struct{}, error) { return &struct{}{}, nil }, location.NoPassword, diff --git a/internal/backend/rclone/backend.go b/internal/backend/rclone/backend.go index 416162364..25082598f 100644 --- a/internal/backend/rclone/backend.go +++ b/internal/backend/rclone/backend.go @@ -183,7 +183,7 @@ func newBackend(ctx context.Context, cfg Config, lim limiter.Limiter) (*Backend, dialCount := 0 tr := &http2.Transport{ AllowHTTP: true, // this is not really HTTP, just stdin/stdout - DialTLS: func(network, address string, cfg *tls.Config) (net.Conn, error) { + DialTLS: func(network, address string, _ *tls.Config) (net.Conn, error) { debug.Log("new connection requested, %v %v", network, address) if dialCount > 0 { // the connection to the child process is already closed diff --git a/internal/checker/checker.go b/internal/checker/checker.go index df865cb41..1e14a9e53 100644 --- a/internal/checker/checker.go +++ b/internal/checker/checker.go @@ -134,7 +134,7 @@ func (c *Checker) LoadIndex(ctx context.Context, p *progress.Counter) (hints []e if p != nil { var numIndexFiles uint64 - err := indexList.List(ctx, restic.IndexFile, func(id restic.ID, size int64) error { + err := indexList.List(ctx, restic.IndexFile, func(_ restic.ID, _ int64) error { numIndexFiles++ return nil }) diff --git a/internal/fs/fs_track.go b/internal/fs/fs_track.go index 319fbfaff..0c65a8564 100644 --- a/internal/fs/fs_track.go +++ b/internal/fs/fs_track.go @@ -41,7 +41,7 @@ type trackFile struct { func newTrackFile(stack []byte, filename string, file File) *trackFile { f := &trackFile{file} - runtime.SetFinalizer(f, func(f *trackFile) { + runtime.SetFinalizer(f, func(_ *trackFile) { fmt.Fprintf(os.Stderr, "file %s not closed\n\nStacktrack:\n%s\n", filename, stack) panic("file " + filename + " not closed") }) diff --git a/internal/fuse/snapshots_dirstruct.go b/internal/fuse/snapshots_dirstruct.go index d40ae6298..049319c6f 100644 --- a/internal/fuse/snapshots_dirstruct.go +++ b/internal/fuse/snapshots_dirstruct.go @@ -295,7 +295,7 @@ func (d *SnapshotsDirStructure) updateSnapshots(ctx context.Context) error { } var snapshots restic.Snapshots - err := d.root.cfg.Filter.FindAll(ctx, d.root.repo, d.root.repo, nil, func(id string, sn *restic.Snapshot, err error) error { + err := d.root.cfg.Filter.FindAll(ctx, d.root.repo, d.root.repo, nil, func(_ string, sn *restic.Snapshot, _ error) error { if sn != nil { snapshots = append(snapshots, sn) } diff --git a/internal/index/index_parallel.go b/internal/index/index_parallel.go index 3c16d049b..d51d5930f 100644 --- a/internal/index/index_parallel.go +++ b/internal/index/index_parallel.go @@ -19,7 +19,7 @@ func ForAllIndexes(ctx context.Context, lister restic.Lister, repo restic.Lister workerCount := repo.Connections() + uint(runtime.GOMAXPROCS(0)) var m sync.Mutex - return restic.ParallelList(ctx, lister, restic.IndexFile, workerCount, func(ctx context.Context, id restic.ID, size int64) error { + return restic.ParallelList(ctx, lister, restic.IndexFile, workerCount, func(ctx context.Context, id restic.ID, _ int64) error { var err error var idx *Index oldFormat := false diff --git a/internal/repository/key.go b/internal/repository/key.go index 5f7a93297..d9f8d8e17 100644 --- a/internal/repository/key.go +++ b/internal/repository/key.go @@ -136,7 +136,7 @@ func SearchKey(ctx context.Context, s *Repository, password string, maxKeys int, defer cancel() // try at most maxKeys keys in repo - err = s.List(listCtx, restic.KeyFile, func(id restic.ID, size int64) error { + err = s.List(listCtx, restic.KeyFile, func(id restic.ID, _ int64) error { checked++ if maxKeys > 0 && checked > maxKeys { return ErrMaxKeysReached diff --git a/internal/repository/repair_pack.go b/internal/repository/repair_pack.go index 64279e727..2e0368899 100644 --- a/internal/repository/repair_pack.go +++ b/internal/repository/repair_pack.go @@ -68,7 +68,7 @@ func RepairPacks(ctx context.Context, repo restic.Repository, ids restic.IDSet, DeleteProgress: func() *progress.Counter { return printer.NewCounter("old indexes deleted") }, - DeleteReport: func(id restic.ID, err error) { + DeleteReport: func(id restic.ID, _ error) { printer.VV("removed index %v", id.String()) }, }) diff --git a/internal/repository/repository.go b/internal/repository/repository.go index a20f71ab1..9a4494c4d 100644 --- a/internal/repository/repository.go +++ b/internal/repository/repository.go @@ -651,7 +651,7 @@ func (r *Repository) LoadIndex(ctx context.Context, p *progress.Counter) error { if p != nil { var numIndexFiles uint64 - err := indexList.List(ctx, restic.IndexFile, func(id restic.ID, size int64) error { + err := indexList.List(ctx, restic.IndexFile, func(_ restic.ID, _ int64) error { numIndexFiles++ return nil }) @@ -662,7 +662,7 @@ func (r *Repository) LoadIndex(ctx context.Context, p *progress.Counter) error { defer p.Done() } - err = index.ForAllIndexes(ctx, indexList, r, func(id restic.ID, idx *index.Index, oldFormat bool, err error) error { + err = index.ForAllIndexes(ctx, indexList, r, func(_ restic.ID, idx *index.Index, _ bool, err error) error { if err != nil { return err } diff --git a/internal/restic/backend_find.go b/internal/restic/backend_find.go index a6eacabd0..2f00595c4 100644 --- a/internal/restic/backend_find.go +++ b/internal/restic/backend_find.go @@ -30,7 +30,7 @@ func Find(ctx context.Context, be Lister, t FileType, prefix string) (ID, error) ctx, cancel := context.WithCancel(ctx) defer cancel() - err := be.List(ctx, t, func(id ID, size int64) error { + err := be.List(ctx, t, func(id ID, _ int64) error { name := id.String() if len(name) >= len(prefix) && prefix == name[:len(prefix)] { if match.IsNull() { diff --git a/internal/restic/lock.go b/internal/restic/lock.go index d98f8ec94..182a3442d 100644 --- a/internal/restic/lock.go +++ b/internal/restic/lock.go @@ -341,7 +341,7 @@ func (l *Lock) checkExistence(ctx context.Context) (bool, error) { exists := false - err := l.repo.List(ctx, LockFile, func(id ID, size int64) error { + err := l.repo.List(ctx, LockFile, func(id ID, _ int64) error { if id.Equal(*l.lockID) { exists = true } @@ -415,7 +415,7 @@ func RemoveStaleLocks(ctx context.Context, repo Repository) (uint, error) { // RemoveAllLocks removes all locks forcefully. func RemoveAllLocks(ctx context.Context, repo Repository) (uint, error) { var processed uint32 - err := ParallelList(ctx, repo, LockFile, repo.Connections(), func(ctx context.Context, id ID, size int64) error { + err := ParallelList(ctx, repo, LockFile, repo.Connections(), func(ctx context.Context, id ID, _ int64) error { err := repo.Backend().Remove(ctx, backend.Handle{Type: LockFile, Name: id.String()}) if err == nil { atomic.AddUint32(&processed, 1) diff --git a/internal/restic/snapshot.go b/internal/restic/snapshot.go index 88171a646..8cf651d96 100644 --- a/internal/restic/snapshot.go +++ b/internal/restic/snapshot.go @@ -83,7 +83,7 @@ func ForAllSnapshots(ctx context.Context, be Lister, loader LoaderUnpacked, excl var m sync.Mutex // For most snapshots decoding is nearly for free, thus just assume were only limited by IO - return ParallelList(ctx, be, SnapshotFile, loader.Connections(), func(ctx context.Context, id ID, size int64) error { + return ParallelList(ctx, be, SnapshotFile, loader.Connections(), func(ctx context.Context, id ID, _ int64) error { if excludeIDs.Has(id) { return nil } diff --git a/internal/restorer/restorer.go b/internal/restorer/restorer.go index 2ce1ee98e..3f4fb32e3 100644 --- a/internal/restorer/restorer.go +++ b/internal/restorer/restorer.go @@ -27,7 +27,7 @@ type Restorer struct { SelectFilter func(item string, dstpath string, node *restic.Node) (selectedForRestore bool, childMayBeSelected bool) } -var restorerAbortOnAllErrors = func(location string, err error) error { return err } +var restorerAbortOnAllErrors = func(_ string, err error) error { return err } // NewRestorer creates a restorer preloaded with the content from the snapshot id. func NewRestorer(repo restic.Repository, sn *restic.Snapshot, sparse bool, @@ -239,7 +239,7 @@ func (res *Restorer) RestoreTo(ctx context.Context, dst string) error { // first tree pass: create directories and collect all files to restore _, err = res.traverseTree(ctx, dst, string(filepath.Separator), *res.sn.Tree, treeVisitor{ - enterDir: func(node *restic.Node, target, location string) error { + enterDir: func(_ *restic.Node, target, location string) error { debug.Log("first pass, enterDir: mkdir %q, leaveDir should restore metadata", location) if res.progress != nil { res.progress.AddFile(0) @@ -366,7 +366,7 @@ func (res *Restorer) VerifyFiles(ctx context.Context, dst string) (int, error) { defer close(work) _, err := res.traverseTree(ctx, dst, string(filepath.Separator), *res.sn.Tree, treeVisitor{ - visitNode: func(node *restic.Node, target, location string) error { + visitNode: func(node *restic.Node, target, _ string) error { if node.Type != "file" { return nil } diff --git a/internal/ui/backup/progress.go b/internal/ui/backup/progress.go index 4362a8c83..da0d401a3 100644 --- a/internal/ui/backup/progress.go +++ b/internal/ui/backup/progress.go @@ -63,7 +63,7 @@ func NewProgress(printer ProgressPrinter, interval time.Duration) *Progress { printer: printer, estimator: *newRateEstimator(time.Now()), } - p.Updater = *progress.NewUpdater(interval, func(runtime time.Duration, final bool) { + p.Updater = *progress.NewUpdater(interval, func(_ time.Duration, final bool) { if final { p.printer.Reset() } else { diff --git a/internal/walker/rewriter.go b/internal/walker/rewriter.go index 649857032..6d283a625 100644 --- a/internal/walker/rewriter.go +++ b/internal/walker/rewriter.go @@ -39,13 +39,13 @@ func NewTreeRewriter(opts RewriteOpts) *TreeRewriter { } // setup default implementations if rw.opts.RewriteNode == nil { - rw.opts.RewriteNode = func(node *restic.Node, path string) *restic.Node { + rw.opts.RewriteNode = func(node *restic.Node, _ string) *restic.Node { return node } } if rw.opts.RewriteFailedTree == nil { // fail with error by default - rw.opts.RewriteFailedTree = func(nodeID restic.ID, path string, err error) (restic.ID, error) { + rw.opts.RewriteFailedTree = func(_ restic.ID, _ string, err error) (restic.ID, error) { return restic.ID{}, err } }