mirror of
https://github.com/kopia/kopia.git
synced 2026-10-20 13:14:45 -04:00
chore(ci): upgraded linter to 1.53.3 (#3079)
* chore(ci): upgraded linter to 1.53.3 This flagged a bunch of unused parameters, so the PR is larger than usual, but 99% mechanical. * separate lint CI task * run Lint in separate CI
This commit is contained in:
1 parent
8eb3893738
commit
cbc66f936d
103 files changed
+332
-132
No files matched your search
+2
-2
@@ -328,9 +328,9 @@ func NewApp() *App {
|
||||
exitWithError: func(err error) {
|
||||
if err != nil {
|
||||
os.Exit(1)
|
||||
} else {
|
||||
os.Exit(0)
|
||||
}
|
||||
|
||||
os.Exit(0)
|
||||
},
|
||||
stdoutWriter: colorable.NewColorableStdout(),
|
||||
stderrWriter: colorable.NewColorableStderr(),
|
||||
|
||||
+3
-3
@@ -66,11 +66,11 @@ type cliProgress struct {
|
||||
progressFlags
|
||||
}
|
||||
|
||||
func (p *cliProgress) HashingFile(fname string) {
|
||||
func (p *cliProgress) HashingFile(_ string) {
|
||||
p.inProgressHashing.Add(1)
|
||||
}
|
||||
|
||||
func (p *cliProgress) FinishedHashingFile(fname string, totalSize int64) {
|
||||
func (p *cliProgress) FinishedHashingFile(_ string, _ int64) {
|
||||
p.hashedFiles.Add(1)
|
||||
p.inProgressHashing.Add(-1)
|
||||
p.maybeOutput()
|
||||
@@ -98,7 +98,7 @@ func (p *cliProgress) Error(path string, err error, isIgnored bool) {
|
||||
}
|
||||
}
|
||||
|
||||
func (p *cliProgress) CachedFile(fname string, numBytes int64) {
|
||||
func (p *cliProgress) CachedFile(_ string, numBytes int64) {
|
||||
p.cachedBytes.Add(numBytes)
|
||||
p.cachedFiles.Add(1)
|
||||
p.maybeOutput()
|
||||
|
||||
@@ -51,7 +51,7 @@ func (c *commandBenchmarkCompression) readInputFile(ctx context.Context) ([]byte
|
||||
return nil, errors.Wrap(err, "error opening input file")
|
||||
}
|
||||
|
||||
defer f.Close() //nolint:errcheck,gosec
|
||||
defer f.Close() //nolint:errcheck
|
||||
|
||||
st, err := f.Stat()
|
||||
if err != nil {
|
||||
|
||||
@@ -178,7 +178,7 @@ func (c *commandBlobShardsModify) run(ctx context.Context) error {
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error creating .shards file")
|
||||
}
|
||||
defer of.Close() //nolint:errcheck,gosec
|
||||
defer of.Close() //nolint:errcheck
|
||||
|
||||
return errors.Wrap(dstPar.Save(of), "error saving .shards file")
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ func (c *commandCacheInfo) setup(svc appServices, parent commandParent) {
|
||||
c.out.setup(svc)
|
||||
}
|
||||
|
||||
func (c *commandCacheInfo) run(ctx context.Context, rep repo.Repository) error {
|
||||
func (c *commandCacheInfo) run(ctx context.Context, _ repo.Repository) error {
|
||||
opts, err := repo.GetCachingOptions(ctx, c.svc.repositoryConfigFileName())
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error getting cache options")
|
||||
|
||||
@@ -42,7 +42,7 @@ func (c *commandCacheSetParams) setup(svc appServices, parent commandParent) {
|
||||
c.svc = svc
|
||||
}
|
||||
|
||||
func (c *commandCacheSetParams) run(ctx context.Context, rep repo.RepositoryWriter) error {
|
||||
func (c *commandCacheSetParams) run(ctx context.Context, _ repo.RepositoryWriter) error {
|
||||
opts, err := repo.GetCachingOptions(ctx, c.svc.repositoryConfigFileName())
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error getting caching options")
|
||||
|
||||
@@ -48,9 +48,5 @@ func (c *policyRetentionFlags) setRetentionPolicyFromFlags(ctx context.Context,
|
||||
}
|
||||
}
|
||||
|
||||
if err := applyPolicyBoolPtr(ctx, "do not save identical snapshots", &rp.IgnoreIdenticalSnapshots, c.policySetIgnoreIdenticalSnapshots, changeCount); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
return applyPolicyBoolPtr(ctx, "do not save identical snapshots", &rp.IgnoreIdenticalSnapshots, c.policySetIgnoreIdenticalSnapshots, changeCount)
|
||||
}
|
||||
@@ -29,9 +29,5 @@ func (c *policyUploadFlags) setUploadPolicyFromFlags(ctx context.Context, up *po
|
||||
return err
|
||||
}
|
||||
|
||||
if err := applyOptionalInt64MiB(ctx, "parallel upload above size", &up.ParallelUploadAboveSize, c.parallelizeUploadAboveSizeMiB, changeCount); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
return applyOptionalInt64MiB(ctx, "parallel upload above size", &up.ParallelUploadAboveSize, c.parallelizeUploadAboveSizeMiB, changeCount)
|
||||
}
|
||||
@@ -25,6 +25,8 @@ func (c *storageFromConfigFlags) Setup(sps StorageProviderServices, cmd *kingpin
|
||||
}
|
||||
|
||||
func (c *storageFromConfigFlags) Connect(ctx context.Context, isCreate bool, formatVersion int) (blob.Storage, error) {
|
||||
_ = formatVersion
|
||||
|
||||
if isCreate {
|
||||
return nil, errors.New("not supported")
|
||||
}
|
||||
|
||||
@@ -132,7 +132,7 @@ func updateRepositoryParameters(
|
||||
if upgradeToEpochManager {
|
||||
log(ctx).Infof("migrating current indexes to epoch format")
|
||||
|
||||
if err := rep.ContentManager().PrepareUpgradeToIndexBlobManagerV1(ctx, mp.EpochParameters); err != nil {
|
||||
if err := rep.ContentManager().PrepareUpgradeToIndexBlobManagerV1(ctx); err != nil {
|
||||
return errors.Wrap(err, "error upgrading indexes")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,13 +82,13 @@ func (c *commandRepositoryStatus) outputJSON(ctx context.Context, r repo.Reposit
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *commandRepositoryStatus) dumpUpgradeStatus(ctx context.Context, dr repo.DirectRepository) error {
|
||||
func (c *commandRepositoryStatus) dumpUpgradeStatus(dr repo.DirectRepository) error {
|
||||
drw, isDr := dr.(repo.DirectRepositoryWriter)
|
||||
if !isDr {
|
||||
return nil
|
||||
}
|
||||
|
||||
l, err := drw.FormatManager().GetUpgradeLockIntent(ctx)
|
||||
l, err := drw.FormatManager().GetUpgradeLockIntent()
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "failed to get the upgrade lock intent")
|
||||
}
|
||||
@@ -218,7 +218,7 @@ func (c *commandRepositoryStatus) run(ctx context.Context, rep repo.Repository)
|
||||
|
||||
c.dumpRetentionStatus(dr)
|
||||
|
||||
if err := c.dumpUpgradeStatus(ctx, dr); err != nil {
|
||||
if err := c.dumpUpgradeStatus(dr); err != nil {
|
||||
return errors.Wrap(err, "failed to dump upgrade status")
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,8 @@ package cli
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
|
||||
"github.com/kopia/kopia/repo"
|
||||
)
|
||||
|
||||
@@ -21,7 +23,7 @@ func (c *commandRepositoryThrottleGet) run(ctx context.Context, rep repo.DirectR
|
||||
limits := rep.Throttler().Limits()
|
||||
|
||||
if err := c.ctg.output(&limits); err != nil {
|
||||
return err
|
||||
return errors.Wrap(err, "output")
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
@@ -361,7 +361,7 @@ func (c *commandRepositoryUpgrade) drainOrCommit(ctx context.Context, rep repo.D
|
||||
if mp.EpochParameters.Enabled {
|
||||
log(ctx).Infof("Repository indices have already been migrated to the epoch format, no need to drain other clients")
|
||||
|
||||
l, err := rep.FormatManager().GetUpgradeLockIntent(ctx)
|
||||
l, err := rep.FormatManager().GetUpgradeLockIntent()
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "failed to get upgrade lock intent")
|
||||
}
|
||||
@@ -404,7 +404,7 @@ func (c *commandRepositoryUpgrade) sleepWithContext(ctx context.Context, dur tim
|
||||
|
||||
func (c *commandRepositoryUpgrade) drainAllClients(ctx context.Context, rep repo.DirectRepositoryWriter) error {
|
||||
for {
|
||||
l, err := rep.FormatManager().GetUpgradeLockIntent(ctx)
|
||||
l, err := rep.FormatManager().GetUpgradeLockIntent()
|
||||
|
||||
upgradeTime := l.UpgradeTime()
|
||||
now := rep.Time()
|
||||
@@ -454,7 +454,7 @@ func (c *commandRepositoryUpgrade) upgrade(ctx context.Context, rep repo.DirectR
|
||||
|
||||
log(ctx).Infof("migrating current indices to epoch format")
|
||||
|
||||
if uerr := rep.ContentManager().PrepareUpgradeToIndexBlobManagerV1(ctx, mp.EpochParameters); uerr != nil {
|
||||
if uerr := rep.ContentManager().PrepareUpgradeToIndexBlobManagerV1(ctx); uerr != nil {
|
||||
return errors.Wrap(uerr, "error upgrading indices")
|
||||
}
|
||||
|
||||
|
||||
@@ -60,6 +60,8 @@ func (ep *estimateProgress) Error(ctx context.Context, filename string, err erro
|
||||
}
|
||||
|
||||
func (ep *estimateProgress) Stats(ctx context.Context, st *snapshot.Stats, included, excluded snapshotfs.SampleBuckets, excludedDirs []string, final bool) {
|
||||
_ = final
|
||||
|
||||
ep.stats = *st
|
||||
ep.included = included
|
||||
ep.excluded = excluded
|
||||
|
||||
@@ -4,6 +4,6 @@ import (
|
||||
"github.com/alecthomas/kingpin/v2"
|
||||
)
|
||||
|
||||
func (c *App) setupOSSpecificKeychainFlags(svc appServices, app *kingpin.Application) {
|
||||
func (c *App) setupOSSpecificKeychainFlags(_ appServices, app *kingpin.Application) {
|
||||
app.Flag("use-keychain", "Use macOS Keychain for storing repository password.").Default("true").BoolVar(&c.keyRingEnabled)
|
||||
}
|
||||
@@ -7,5 +7,6 @@ import (
|
||||
"github.com/alecthomas/kingpin/v2"
|
||||
)
|
||||
|
||||
//nolint:revive
|
||||
func (c *App) setupOSSpecificKeychainFlags(svc appServices, app *kingpin.Application) {
|
||||
}
|
||||
@@ -4,6 +4,6 @@ import (
|
||||
"github.com/alecthomas/kingpin/v2"
|
||||
)
|
||||
|
||||
func (c *App) setupOSSpecificKeychainFlags(svc appServices, app *kingpin.Application) {
|
||||
func (c *App) setupOSSpecificKeychainFlags(_ appServices, app *kingpin.Application) {
|
||||
app.Flag("use-credential-manager", "Use Windows Credential Manager for storing repository password.").Default("true").BoolVar(&c.keyRingEnabled)
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package cli
|
||||
|
||||
//nolint:revive
|
||||
func onExternalConfigReloadRequest(f func()) {
|
||||
// SIGHUP not supported on Windows.
|
||||
}
|
||||
@@ -25,6 +25,8 @@ func (c *storageAzureFlags) Setup(svc StorageProviderServices, cmd *kingpin.CmdC
|
||||
}
|
||||
|
||||
func (c *storageAzureFlags) Connect(ctx context.Context, isCreate bool, formatVersion int) (blob.Storage, error) {
|
||||
_ = formatVersion
|
||||
|
||||
//nolint:wrapcheck
|
||||
return azure.New(ctx, &c.azOptions, false)
|
||||
return azure.New(ctx, &c.azOptions, isCreate)
|
||||
}
|
||||
+3
-1
@@ -22,6 +22,8 @@ func (c *storageB2Flags) Setup(svc StorageProviderServices, cmd *kingpin.CmdClau
|
||||
}
|
||||
|
||||
func (c *storageB2Flags) Connect(ctx context.Context, isCreate bool, formatVersion int) (blob.Storage, error) {
|
||||
_ = formatVersion
|
||||
|
||||
//nolint:wrapcheck
|
||||
return b2.New(ctx, &c.b2options, false)
|
||||
return b2.New(ctx, &c.b2options, isCreate)
|
||||
}
|
||||
+3
-1
@@ -29,6 +29,8 @@ func (c *storageGCSFlags) Setup(_ StorageProviderServices, cmd *kingpin.CmdClaus
|
||||
}
|
||||
|
||||
func (c *storageGCSFlags) Connect(ctx context.Context, isCreate bool, formatVersion int) (blob.Storage, error) {
|
||||
_ = formatVersion
|
||||
|
||||
if c.embedCredentials {
|
||||
data, err := os.ReadFile(c.options.ServiceAccountCredentialsFile)
|
||||
if err != nil {
|
||||
@@ -40,5 +42,5 @@ func (c *storageGCSFlags) Connect(ctx context.Context, isCreate bool, formatVers
|
||||
}
|
||||
|
||||
//nolint:wrapcheck
|
||||
return gcs.New(ctx, &c.options, false)
|
||||
return gcs.New(ctx, &c.options, isCreate)
|
||||
}
|
||||
@@ -28,6 +28,8 @@ func (c *storageGDriveFlags) Setup(_ StorageProviderServices, cmd *kingpin.CmdCl
|
||||
}
|
||||
|
||||
func (c *storageGDriveFlags) Connect(ctx context.Context, isCreate bool, formatVersion int) (blob.Storage, error) {
|
||||
_ = formatVersion
|
||||
|
||||
if c.embedCredentials {
|
||||
data, err := os.ReadFile(c.options.ServiceAccountCredentialsFile)
|
||||
if err != nil {
|
||||
@@ -39,5 +41,5 @@ func (c *storageGDriveFlags) Connect(ctx context.Context, isCreate bool, formatV
|
||||
}
|
||||
|
||||
//nolint:wrapcheck
|
||||
return gdrive.New(ctx, &c.options, false)
|
||||
return gdrive.New(ctx, &c.options, isCreate)
|
||||
}
|
||||
+5
-3
@@ -53,7 +53,7 @@ func (c *storageS3Flags) Setup(svc StorageProviderServices, cmd *kingpin.CmdClau
|
||||
cmd.Flag("root-ca-pem-path", "Certficate authority file path").PreAction(c.preActionLoadPEMPath).StringVar(&c.rootCaPemPath)
|
||||
}
|
||||
|
||||
func (c *storageS3Flags) preActionLoadPEMPath(pc *kingpin.ParseContext) error {
|
||||
func (c *storageS3Flags) preActionLoadPEMPath(_ *kingpin.ParseContext) error {
|
||||
if len(c.s3options.RootCA) > 0 {
|
||||
return errors.Errorf("root-ca-pem-base64 and root-ca-pem-path are mutually exclusive")
|
||||
}
|
||||
@@ -68,7 +68,7 @@ func (c *storageS3Flags) preActionLoadPEMPath(pc *kingpin.ParseContext) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *storageS3Flags) preActionLoadPEMBase64(pc *kingpin.ParseContext) error {
|
||||
func (c *storageS3Flags) preActionLoadPEMBase64(_ *kingpin.ParseContext) error {
|
||||
caContent, err := base64.StdEncoding.DecodeString(c.rootCaPemBase64)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "unable to decode CA")
|
||||
@@ -80,10 +80,12 @@ func (c *storageS3Flags) preActionLoadPEMBase64(pc *kingpin.ParseContext) error
|
||||
}
|
||||
|
||||
func (c *storageS3Flags) Connect(ctx context.Context, isCreate bool, formatVersion int) (blob.Storage, error) {
|
||||
_ = formatVersion
|
||||
|
||||
if isCreate && c.s3options.PointInTime != nil && !c.s3options.PointInTime.IsZero() {
|
||||
return nil, errors.New("Cannot specify a 'point-in-time' option when creating a repository")
|
||||
}
|
||||
|
||||
//nolint:wrapcheck
|
||||
return s3.New(ctx, &c.s3options, false)
|
||||
return s3.New(ctx, &c.s3options, isCreate)
|
||||
}
|
||||
+1
-5
@@ -56,11 +56,7 @@ func (c *commonThrottleSet) apply(ctx context.Context, limits *throttling.Limits
|
||||
return err
|
||||
}
|
||||
|
||||
if err := c.setThrottleInt(ctx, "concurrent writes", &limits.ConcurrentWrites, c.setConcurrentWrites, changeCount); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
return c.setThrottleInt(ctx, "concurrent writes", &limits.ConcurrentWrites, c.setConcurrentWrites, changeCount)
|
||||
}
|
||||
|
||||
func (c *commonThrottleSet) setThrottleFloat64(ctx context.Context, desc string, bps bool, val *float64, str string, changeCount *int) error {
|
||||
|
||||
+1
-1
@@ -73,7 +73,7 @@ func (c *App) getUpdateState() (*updateState, error) {
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "unable to open update state file")
|
||||
}
|
||||
defer f.Close() //nolint:errcheck,gosec
|
||||
defer f.Close() //nolint:errcheck
|
||||
|
||||
us := &updateState{}
|
||||
if err := json.NewDecoder(f).Decode(us); err != nil {
|
||||
|
||||
Reference in new issue
Block a user