Skip to content

Commit

Permalink
refactor: remove unused functions and variables
Browse files Browse the repository at this point in the history
  • Loading branch information
G-Rath committed Mar 2, 2025
1 parent c8893b0 commit 5d8c75b
Show file tree
Hide file tree
Showing 8 changed files with 3 additions and 104 deletions.
2 changes: 1 addition & 1 deletion .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ linters:
- thelper
- unconvert
# - unparam
# - unused
- unused
# - usestdlibvars
- wastedassign
- whitespace
Expand Down
15 changes: 0 additions & 15 deletions artifact/image/layerscanning/image/layer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -584,21 +584,6 @@ func TestChainFSReadDir(t *testing.T) {
// CHAINLAYER TESTING HELPER METHODS
// ========================================================

func checkError(t *testing.T, funcName string, gotErr error, wantErr error) {
t.Helper()
if wantErr != nil {
if !errors.Is(gotErr, wantErr) {
t.Fatalf("%s returned error: %v, want error: %v", funcName, gotErr, wantErr)
}
return
}

if gotErr != nil {
t.Fatalf("%s returned error: %v", funcName, gotErr)
return
}
}

func setUpEmptyChainFS(t *testing.T) FS {
t.Helper()

Expand Down
21 changes: 0 additions & 21 deletions binary/cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,19 +223,6 @@ func validateImagePlatform(imagePlatform string) error {
return nil
}

func validateSPDXCreators(creators string) error {
if len(creators) == 0 {
return nil
}
for _, item := range strings.Split(creators, ",") {
c := strings.Split(item, ":")
if len(c) != 2 {
return fmt.Errorf("invalid spdx-creators format, should follow a format like --spdx-creators=Tool:SCALIBR,Organization:Google")
}
}
return nil
}

func validateMultiStringArg(arg []string) error {
if len(arg) == 0 {
return nil
Expand Down Expand Up @@ -589,11 +576,3 @@ func (f *Flags) dirsToSkip(scanRoots []*scalibrfs.ScanRoot) []string {
}
return result
}

func keys(m map[string][]string) []string {
ret := make([]string, 0, len(m))
for k := range m {
ret = append(ret, k)
}
return ret
}
25 changes: 0 additions & 25 deletions detector/cve/cve202338408/semantic/utilities.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,9 @@
package semantic

import (
"fmt"
"math/big"
)

func convertToBigIntOrPanic(str string) *big.Int {
if num, isNumber := convertToBigInt(str); isNumber {
return num
}

panic(fmt.Sprintf("failed to convert %s to a number", str))
}

func convertToBigInt(str string) (*big.Int, bool) {
i, ok := new(big.Int).SetString(str, 10)

Expand All @@ -40,19 +31,3 @@ func minInt(x, y int) int {

return x
}

func maxInt(x, y int) int {
if x < y {
return y
}

return x
}

func fetch(slice []string, i int, def string) string {
if len(slice) <= i {
return def
}

return slice[i]
}
16 changes: 0 additions & 16 deletions extractor/filesystem/language/javascript/yarnlock/yarnlock.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,22 +46,6 @@ var (
// Format for yarn.lock v1: `resolved "git+ssh://[email protected]:G-Rath/repo-2#hash"`
// Format for yarn.lock v2: `resolution: "@my-scope/my-first-package@https://github.com/my-org/my-first-package.git#commit=hash"`
yarnPackageResolutionRe = regexp.MustCompile(`^ {2}"?(?:resolution:|resolved)"? "([^ '"]+)"$`)
// Regexes for matching commit hashes in the resolution.
commitMatchers = []*regexp.Regexp{
// ssh://...
// git://...
// git+ssh://...
// git+https://...
regexp.MustCompile(`(?:^|.+@)(?:git(?:\+(?:ssh|https))?|ssh)://.+#(\w+)$`),
// https://....git/...
regexp.MustCompile(`(?:^|.+@)https://.+\.git#(\w+)$`),
regexp.MustCompile(`https://codeload\.github\.com(?:/[\w-.]+){2}/tar\.gz/(\w+)$`),
regexp.MustCompile(`.+#commit[:=](\w+)$`),
// github:...
// gitlab:...
// bitbucket:...
regexp.MustCompile(`^(?:github|gitlab|bitbucket):.+#(\w+)$`),
}
)

func shouldSkipYarnLine(line string) bool {
Expand Down
12 changes: 0 additions & 12 deletions extractor/filesystem/language/python/setup/setup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -390,15 +390,3 @@ func TestToPURL(t *testing.T) {
t.Errorf("ToPURL(%v) (-want +got):\n%s", i, diff)
}
}

func defaultConfigWith(cfg setup.Config) setup.Config {
newCfg := setup.DefaultConfig()

if cfg.MaxFileSizeBytes > 0 {
newCfg.MaxFileSizeBytes = cfg.MaxFileSizeBytes
}
if cfg.Stats != nil {
newCfg.Stats = cfg.Stats
}
return newCfg
}
7 changes: 2 additions & 5 deletions internal/guidedremediation/manifest/maven/pomxml_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,8 @@ import (
)

var (
depMgmt = depTypeWithOrigin("management")
depParent = depTypeWithOrigin("parent")
depPlugin = depTypeWithOrigin("[email protected]:plugin")
depProfileOne = depTypeWithOrigin("profile@profile-one")
depProfileTwoMgmt = depTypeWithOrigin("profile@profile-two@management")
depMgmt = depTypeWithOrigin("management")
depParent = depTypeWithOrigin("parent")
)

func depTypeWithOrigin(origin string) dep.Type {
Expand Down
9 changes: 0 additions & 9 deletions scalibr.go
Original file line number Diff line number Diff line change
Expand Up @@ -332,15 +332,6 @@ func newScanResult(o *newScanResultOptions) *ScanResult {
return r
}

func hasFailedPlugins(statuses []*plugin.Status) bool {
for _, s := range statuses {
if s.Status.Status != plugin.ScanStatusSucceeded {
return true
}
}
return false
}

// sortResults sorts the result to make the output deterministic and diffable.
func sortResults(results *ScanResult) {
for _, inventory := range results.Inventories {
Expand Down

0 comments on commit 5d8c75b

Please sign in to comment.