Address new linter complaints

This commit is contained in:
Katrina Verey
2022-03-29 18:18:23 -04:00
parent b368b347d1
commit 14947e449b
77 changed files with 220 additions and 210 deletions

View File

@@ -113,7 +113,6 @@ func debug(fMap filterMap) {
// 'spec/scaleTargetRef/name' field. Return a filter that can do that.
func (t *nameReferenceTransformer) determineFilters(
resources []*resource.Resource) (fMap filterMap) {
// We cache the resource OrgId values because they don't change and otherwise are very visible in a memory pprof
resourceOrgIds := make([]resid.ResId, len(resources))
for i, resource := range resources {

View File

@@ -107,7 +107,6 @@ func (ra *ResAccumulator) findVarValueFromResources(v types.Var) (interface{}, e
for _, res := range ra.resMap.Resources() {
for _, varName := range res.GetRefVarNames() {
if varName == v.Name {
//nolint: staticcheck
s, err := res.GetFieldValue(v.FieldRef.FieldPath)
if err != nil {
return "", fmt.Errorf(

View File

@@ -78,15 +78,15 @@ func (x *RepoSpec) Cleaner(fSys filesys.FileSystem) func() error {
return func() error { return fSys.RemoveAll(x.Dir.String()) }
}
// NewRepoSpecFromUrl parses git-like urls.
// NewRepoSpecFromURL parses git-like urls.
// From strings like git@github.com:someOrg/someRepo.git or
// https://github.com/someOrg/someRepo?ref=someHash, extract
// the parts.
func NewRepoSpecFromUrl(n string) (*RepoSpec, error) {
func NewRepoSpecFromURL(n string) (*RepoSpec, error) {
if filepath.IsAbs(n) {
return nil, fmt.Errorf("uri looks like abs path: %s", n)
}
host, orgRepo, path, gitRef, gitSubmodules, suffix, gitTimeout := parseGitUrl(n)
host, orgRepo, path, gitRef, gitSubmodules, suffix, gitTimeout := parseGitURL(n)
if orgRepo == "" {
return nil, fmt.Errorf("url lacks orgRepo: %s", n)
}
@@ -108,9 +108,8 @@ const (
// From strings like git@github.com:someOrg/someRepo.git or
// https://github.com/someOrg/someRepo?ref=someHash, extract
// the parts.
func parseGitUrl(n string) (
func parseGitURL(n string) (
host string, orgRepo string, path string, gitRef string, gitSubmodules bool, gitSuff string, gitTimeout time.Duration) {
if strings.Contains(n, gitDelimiter) {
index := strings.Index(n, gitDelimiter)
// Adding _git/ to host
@@ -229,7 +228,7 @@ func parseHostSpec(n string) (string, string) {
if strings.HasSuffix(host, p) {
i := strings.Index(n, "/")
if i > -1 {
host = host + n[0:i+1]
host += n[0 : i+1]
n = n[i+1:]
}
break

View File

@@ -37,7 +37,7 @@ var hostNamesRawAndNormalized = [][]string{
{"git@github.com/", "git@github.com:"},
}
func makeUrl(hostFmt, orgRepo, path, href string) string {
func makeURL(hostFmt, orgRepo, path, href string) string {
if len(path) > 0 {
orgRepo = filepath.Join(orgRepo, path)
}
@@ -56,8 +56,8 @@ func TestNewRepoSpecFromUrl(t *testing.T) {
for _, orgRepo := range orgRepos {
for _, pathName := range pathNames {
for _, hrefArg := range hrefArgs {
uri := makeUrl(hostRaw, orgRepo, pathName, hrefArg)
rs, err := NewRepoSpecFromUrl(uri)
uri := makeURL(hostRaw, orgRepo, pathName, hrefArg)
rs, err := NewRepoSpecFromURL(uri)
if err != nil {
t.Errorf("problem %v", err)
}
@@ -99,7 +99,7 @@ var badData = [][]string{
func TestNewRepoSpecFromUrlErrors(t *testing.T) {
for _, tuple := range badData {
_, err := NewRepoSpecFromUrl(tuple[0])
_, err := NewRepoSpecFromURL(tuple[0])
if err == nil {
t.Error("expected error")
}
@@ -191,7 +191,7 @@ func TestNewRepoSpecFromUrl_CloneSpecs(t *testing.T) {
}
for tn, tc := range testcases {
t.Run(tn, func(t *testing.T) {
rs, err := NewRepoSpecFromUrl(tc.input)
rs, err := NewRepoSpecFromURL(tc.input)
assert.NoError(t, err)
assert.Equal(t, tc.cloneSpec, rs.CloneSpec(), "cloneSpec mismatch")
assert.Equal(t, tc.absPath, rs.AbsPath(), "absPath mismatch")

View File

@@ -36,7 +36,7 @@ const (
var stringToBuiltinPluginTypeMap map[string]BuiltinPluginType
func init() {
func init() { //nolint:gochecknoinits
stringToBuiltinPluginTypeMap = makeStringToBuiltinPluginTypeMap()
}

View File

@@ -83,7 +83,6 @@ metadata:
`
if expected != string(p.Cfg()) {
t.Fatalf("expected cfg '%s', got '%s'", expected, string(p.Cfg()))
}
if len(p.Args()) != 6 {
t.Fatalf("unexpected arg len %d, %#v", len(p.Args()), p.Args())

View File

@@ -105,10 +105,10 @@ func TestUpdateResourceOptionsWithInvalidHashAnnotationValues(t *testing.T) {
"TrUe",
"potato",
}
for i, c := range cases {
for i := range cases {
name := fmt.Sprintf("test%d", i)
in := resmap.New()
err := in.Append(makeConfigMap(rf, name, "", &c))
err := in.Append(makeConfigMap(rf, name, "", &cases[i]))
require.NoError(t, err)
_, err = UpdateResourceOptions(in)
require.Error(t, err)