From a7f5dd42a61ff3c520e4bdf749f1974fdd72a2ba Mon Sep 17 00:00:00 2001 From: Adam Hughes <9903835+tri-adam@users.noreply.github.com> Date: Fri, 23 Sep 2022 17:15:03 +0000 Subject: [PATCH] chore: remove unused code Replace deprecated 'deadcode' linter, replacing it with 'unused'. Address lint found by 'unused'. --- .golangci.yml | 2 +- e2e/instance/instance_utils.go | 19 +------------------ e2e/sign/sign.go | 1 - .../pkg/build/sources/conveyorPacker_local.go | 3 +-- .../pkg/build/sources/conveyorPacker_shub.go | 5 ++--- internal/pkg/cache/cache.go | 15 --------------- 6 files changed, 5 insertions(+), 40 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index c70bba2a68..7dbe5aa448 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -18,7 +18,6 @@ linters: enable: - containedctx - contextcheck - - deadcode - decorder - dupl - gofumpt @@ -32,6 +31,7 @@ linters: - nakedret - revive - staticcheck + - unused linters-settings: misspell: diff --git a/e2e/instance/instance_utils.go b/e2e/instance/instance_utils.go index ab84d6fa01..8dfd15078c 100644 --- a/e2e/instance/instance_utils.go +++ b/e2e/instance/instance_utils.go @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2021, Sylabs Inc. All rights reserved. +// Copyright (c) 2019-2022, Sylabs Inc. All rights reserved. // This software is licensed under a 3-clause BSD license. Please consult the // LICENSE.md file distributed with the sources of this project regarding your // rights to use or distribute this software. @@ -29,23 +29,6 @@ type instanceList struct { Instances []instance `json:"instances"` } -func (c *ctx) listInstance(t *testing.T, listArgs ...string) (stdout string, stderr string, success bool) { - var args []string - - c.env.RunSingularity( - t, - e2e.WithProfile(c.profile), - e2e.WithCommand("instance list"), - e2e.WithArgs(args...), - e2e.PostRun(func(t *testing.T) { - success = !t.Failed() - }), - e2e.ExpectExit(0, e2e.GetStreams(&stdout, &stderr)), - ) - - return -} - func (c *ctx) stopInstance(t *testing.T, instance string, stopArgs ...string) (stdout string, stderr string, success bool) { args := stopArgs diff --git a/e2e/sign/sign.go b/e2e/sign/sign.go index 2113c1a6d7..fbdddae5c5 100644 --- a/e2e/sign/sign.go +++ b/e2e/sign/sign.go @@ -16,7 +16,6 @@ import ( type ctx struct { env e2e.TestEnv - imgCache string keyringDir string passphraseInput []e2e.SingularityConsoleOp } diff --git a/internal/pkg/build/sources/conveyorPacker_local.go b/internal/pkg/build/sources/conveyorPacker_local.go index b2e388a23e..d3c7cb9a89 100644 --- a/internal/pkg/build/sources/conveyorPacker_local.go +++ b/internal/pkg/build/sources/conveyorPacker_local.go @@ -1,4 +1,4 @@ -// Copyright (c) 2018-2020, Sylabs Inc. All rights reserved. +// Copyright (c) 2018-2022, Sylabs Inc. All rights reserved. // This software is licensed under a 3-clause BSD license. Please consult the // LICENSE.md file distributed with the sources of this project regarding your // rights to use or distribute this software. @@ -19,7 +19,6 @@ import ( // LocalConveyor only needs to hold the conveyor to have the needed data to pack type LocalConveyor struct { src string - b *types.Bundle } // LocalPacker ... diff --git a/internal/pkg/build/sources/conveyorPacker_shub.go b/internal/pkg/build/sources/conveyorPacker_shub.go index e59f298fab..f3d221f30a 100644 --- a/internal/pkg/build/sources/conveyorPacker_shub.go +++ b/internal/pkg/build/sources/conveyorPacker_shub.go @@ -1,4 +1,4 @@ -// Copyright (c) 2018-2020, Sylabs Inc. All rights reserved. +// Copyright (c) 2018-2022, Sylabs Inc. All rights reserved. // This software is licensed under a 3-clause BSD license. Please consult the // LICENSE.md file distributed with the sources of this project regarding your // rights to use or distribute this software. @@ -16,8 +16,7 @@ import ( // ShubConveyorPacker only needs to hold the conveyor to have the needed data to pack. type ShubConveyorPacker struct { - recipe types.Definition - b *types.Bundle + b *types.Bundle LocalPacker } diff --git a/internal/pkg/cache/cache.go b/internal/pkg/cache/cache.go index b6b453647a..5da437a87f 100644 --- a/internal/pkg/cache/cache.go +++ b/internal/pkg/cache/cache.go @@ -200,21 +200,6 @@ func (h *Handle) CleanCache(cacheType string, dryRun bool, days int) (err error) return err } -// cleanAllCaches is an utility function that wipes all files in the -// cache directory, will return a error if one occurs -func (h *Handle) cleanAllCaches() { - if h.disabled { - return - } - - for _, ct := range append(FileCacheTypes, OciCacheTypes...) { - dir := h.getCacheTypeDir(ct) - if err := os.RemoveAll(dir); err != nil { - sylog.Verbosef("unable to clean %s cache, directory %s: %v", ct, dir, err) - } - } -} - // IsDisabled returns true if the cache is disabled func (h *Handle) IsDisabled() bool { return h.disabled