Skip to content

Commit 41d9070

Browse files
committed
Fix linting issues
1 parent 791b8b3 commit 41d9070

File tree

7 files changed

+67
-36
lines changed

7 files changed

+67
-36
lines changed

.golangci.yaml

Lines changed: 0 additions & 26 deletions
This file was deleted.

.golangci.yml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
run:
2+
timeout: 10m
3+
allow-parallel-runners: true
4+
5+
issues:
6+
# don't skip warning about doc comments
7+
# don't exclude the default set of lint
8+
exclude-use-default: false
9+
# restore some of the defaults
10+
# (fill in the rest as needed)
11+
exclude-rules:
12+
- path: "clientutils/*"
13+
linters:
14+
- lll
15+
- path: "envtestutils/*"
16+
linters:
17+
- lll
18+
- path: "unstructuredutils/*"
19+
linters:
20+
- lll
21+
- path: "metautils/*"
22+
linters:
23+
- lll
24+
- path: "kustomizeutils/*"
25+
linters:
26+
- lll
27+
- path: "configutils/*"
28+
linters:
29+
- lll
30+
- path: "conditionutils/*"
31+
linters:
32+
- lll
33+
- path: "testutils/*"
34+
linters:
35+
- lll
36+
- path: "cmdutils/*"
37+
linters:
38+
- dupl
39+
linters:
40+
disable-all: true
41+
enable:
42+
- copyloopvar
43+
- dupl
44+
- errcheck
45+
- goconst
46+
- gocyclo
47+
- gofmt
48+
- goimports
49+
- gosimple
50+
- govet
51+
- ineffassign
52+
- ginkgolinter
53+
- lll
54+
- misspell
55+
- nakedret
56+
- prealloc
57+
- staticcheck
58+
- typecheck
59+
- unconvert
60+
- unparam
61+
- unused

clientutils/clientutils.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -488,10 +488,9 @@ func CreateOrUseAndPatch(
488488
var (
489489
base = obj.DeepCopyObject().(client.Object)
490490
best client.Object
491-
other []client.Object
491+
other = make([]client.Object, 0, len(objects))
492492
)
493493
for _, object := range objects {
494-
object := object
495494
if err := setObject(obj, object); err != nil {
496495
return controllerutil.OperationResultNone, nil, err
497496
}

conditionutils/conditionutils.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ func getAndConvertField(v reflect.Value, name string, into interface{}) error {
116116
// Otherwise, it returns a pointer to that value.
117117
func direct(v reflect.Value) reflect.Value {
118118
if v.IsZero() {
119-
return reflect.New(reflect.PtrTo(v.Type())).Elem()
119+
return reflect.New(reflect.PointerTo(v.Type())).Elem()
120120
}
121121

122122
res := reflect.New(v.Type())

metautils/metautils.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,13 @@ func ConvertAndSetList(scheme *runtime.Scheme, list runtime.Object, objs []runti
2828
return err
2929
}
3030

31-
var converted []runtime.Object
32-
for _, obj := range objs {
31+
converted := make([]runtime.Object, len(objs))
32+
for i, obj := range objs {
3333
into := reflect.New(elemType).Interface()
3434
if err := scheme.Convert(obj, into, nil); err != nil {
3535
return err
3636
}
37-
38-
converted = append(converted, into.(runtime.Object))
37+
converted[i] = into.(runtime.Object)
3938
}
4039
return meta.SetList(list, converted)
4140
}

modutils/modutils.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,6 @@ func (e *Executor) GetE(name string) (*Module, error) {
9999
continue
100100
}
101101

102-
mod := mod
103102
return &mod, nil
104103
}
105104
return nil, fmt.Errorf("module %q not found", name)

unstructuredutils/unstructuredutils.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ func Read(r io.Reader) ([]unstructured.Unstructured, error) {
6363
for {
6464
ext := runtime.RawExtension{}
6565
if err := d.Decode(&ext); err != nil {
66-
if !errors.Is(io.EOF, err) {
66+
if !errors.Is(err, io.EOF) {
6767
return nil, fmt.Errorf("error parsing: %w", err)
6868
}
6969
return objs, nil
@@ -107,7 +107,6 @@ func UnstructuredSliceToObjectSlice(unstructureds []unstructured.Unstructured) [
107107
}
108108
res := make([]client.Object, 0, len(unstructureds))
109109
for _, u := range unstructureds {
110-
u := u
111110
res = append(res, &u)
112111
}
113112
return res

0 commit comments

Comments
 (0)