From 3dbeb76450d05e8e238146fd5bea9555ba0ea59a Mon Sep 17 00:00:00 2001 From: Eran Turgeman Date: Wed, 26 Jul 2023 17:12:39 +0300 Subject: [PATCH] fixed static analysis issues --- build/utils/yarn.go | 1 - build/utils/yarn_test.go | 13 +++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/build/utils/yarn.go b/build/utils/yarn.go index f5c93518..96a35ce2 100644 --- a/build/utils/yarn.go +++ b/build/utils/yarn.go @@ -118,7 +118,6 @@ func GetYarnDependencies(executablePath, srcPath string, packageInfo *PackageInf if responseStr == "" { return } - err = nil } if isV2AndAbove { diff --git a/build/utils/yarn_test.go b/build/utils/yarn_test.go index 47027bc1..5666427d 100644 --- a/build/utils/yarn_test.go +++ b/build/utils/yarn_test.go @@ -72,7 +72,8 @@ func CheckGetYarnDependencies(t *testing.T, versionDir string, expectedLocators // (i.e. new dependencies added) make sure to fix the checks below assert.Len(t, dependenciesMap, 6) for key, val := range dependenciesMap { - if strings.HasPrefix(key, "react") { + switch { + case strings.HasPrefix(key, "react"): assert.Equal(t, val.Details.Version, "18.2.0") assert.True(t, val.Details.Dependencies != nil) subDependencies := []string{"loose-envify"} @@ -80,17 +81,17 @@ func CheckGetYarnDependencies(t *testing.T, versionDir string, expectedLocators packageName := depPointer.Locator[:strings.Index(depPointer.Locator[1:], "@")+1] assert.Contains(t, subDependencies, packageName) } - } else if strings.HasPrefix(key, "xml") { + case strings.HasPrefix(key, "xml"): assert.Equal(t, val.Details.Version, "1.0.1") assert.True(t, val.Details.Dependencies == nil) - } else if strings.HasPrefix(key, "json") { + case strings.HasPrefix(key, "json"): assert.Equal(t, val.Details.Version, "9.0.6") assert.True(t, val.Details.Dependencies == nil) - } else if strings.HasPrefix(key, "loose-envify") { + case strings.HasPrefix(key, "loose-envify"): assert.True(t, val.Details.Dependencies != nil) - } else if strings.HasPrefix(key, "js-tokens") { + case strings.HasPrefix(key, "js-tokens"): assert.True(t, val.Details.Dependencies == nil) - } else { + default: if key != root.Value { assert.Error(t, errors.New("Package"+key+"should not be inside the dependencyMap")) }