Skip to content

Commit

Permalink
Fix linting issues
Browse files Browse the repository at this point in the history
  • Loading branch information
afritzler committed Oct 1, 2024
1 parent 791b8b3 commit c31c175
Show file tree
Hide file tree
Showing 8 changed files with 68 additions and 37 deletions.
26 changes: 0 additions & 26 deletions .golangci.yaml

This file was deleted.

61 changes: 61 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
run:
timeout: 10m
allow-parallel-runners: true

issues:
# don't skip warning about doc comments
# don't exclude the default set of lint
exclude-use-default: false
# restore some of the defaults
# (fill in the rest as needed)
exclude-rules:
- path: "clientutils/*"
linters:
- lll
- path: "envtestutils/*"
linters:
- lll
- path: "unstructuredutils/*"
linters:
- lll
- path: "metautils/*"
linters:
- lll
- path: "kustomizeutils/*"
linters:
- lll
- path: "configutils/*"
linters:
- lll
- path: "conditionutils/*"
linters:
- lll
- path: "testutils/*"
linters:
- lll
- path: "cmdutils/*"
linters:
- dupl
linters:
disable-all: true
enable:
- copyloopvar
- dupl
- errcheck
- goconst
- gocyclo
- gofmt
- goimports
- gosimple
- govet
- ineffassign
- ginkgolinter
- lll
- misspell
- nakedret
- prealloc
- staticcheck
- typecheck
- unconvert
- unparam
- unused
2 changes: 1 addition & 1 deletion .reuse/dep5
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Source: https://github.com/ironcore-dev/controller-utils
Files:
.github/*
.gitignore
.golangci.yaml
.golangci.yml
CODEOWNERS
CODE_OF_CONDUCT.md
CONTRIBUTING.md
Expand Down
3 changes: 1 addition & 2 deletions clientutils/clientutils.go
Original file line number Diff line number Diff line change
Expand Up @@ -488,10 +488,9 @@ func CreateOrUseAndPatch(
var (
base = obj.DeepCopyObject().(client.Object)
best client.Object
other []client.Object
other = make([]client.Object, 0, len(objects))
)
for _, object := range objects {
object := object
if err := setObject(obj, object); err != nil {
return controllerutil.OperationResultNone, nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion conditionutils/conditionutils.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ func getAndConvertField(v reflect.Value, name string, into interface{}) error {
// Otherwise, it returns a pointer to that value.
func direct(v reflect.Value) reflect.Value {
if v.IsZero() {
return reflect.New(reflect.PtrTo(v.Type())).Elem()
return reflect.New(reflect.PointerTo(v.Type())).Elem()
}

res := reflect.New(v.Type())
Expand Down
7 changes: 3 additions & 4 deletions metautils/metautils.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,13 @@ func ConvertAndSetList(scheme *runtime.Scheme, list runtime.Object, objs []runti
return err
}

var converted []runtime.Object
for _, obj := range objs {
converted := make([]runtime.Object, len(objs))
for i, obj := range objs {
into := reflect.New(elemType).Interface()
if err := scheme.Convert(obj, into, nil); err != nil {
return err
}

converted = append(converted, into.(runtime.Object))
converted[i] = into.(runtime.Object)
}
return meta.SetList(list, converted)
}
Expand Down
1 change: 0 additions & 1 deletion modutils/modutils.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ func (e *Executor) GetE(name string) (*Module, error) {
continue
}

mod := mod
return &mod, nil
}
return nil, fmt.Errorf("module %q not found", name)
Expand Down
3 changes: 1 addition & 2 deletions unstructuredutils/unstructuredutils.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func Read(r io.Reader) ([]unstructured.Unstructured, error) {
for {
ext := runtime.RawExtension{}
if err := d.Decode(&ext); err != nil {
if !errors.Is(io.EOF, err) {
if !errors.Is(err, io.EOF) {
return nil, fmt.Errorf("error parsing: %w", err)
}
return objs, nil
Expand Down Expand Up @@ -107,7 +107,6 @@ func UnstructuredSliceToObjectSlice(unstructureds []unstructured.Unstructured) [
}
res := make([]client.Object, 0, len(unstructureds))
for _, u := range unstructureds {
u := u
res = append(res, &u)
}
return res
Expand Down

0 comments on commit c31c175

Please sign in to comment.