Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: enable nakedret linter #341

Merged
merged 1 commit into from
Jun 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ linters:
- unparam
- unused
- wastedassign
- nakedret
linters-settings:
gci:
sections:
Expand Down
4 changes: 2 additions & 2 deletions controller/controlplane/controller_watch.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ func (r *Reconciler) getControlPlanesFromDataPlane(ctx context.Context, obj clie
"failed to map ControlPlane on DataPlane",
"expected", "DataPlane", "found", reflect.TypeOf(obj),
)
return
return nil
}

controlPlaneList := &operatorv1beta1.ControlPlaneList{}
Expand All @@ -213,7 +213,7 @@ func (r *Reconciler) getControlPlanesFromDataPlane(ctx context.Context, obj clie
index.DataPlaneNameIndex: dataplane.Name,
}); err != nil {
log.FromContext(ctx).Error(err, "failed to map ControlPlane on DataPlane")
return
return nil
}

recs = make([]reconcile.Request, 0, len(controlPlaneList.Items))
Expand Down
12 changes: 6 additions & 6 deletions controller/gateway/controller_watch.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ func (r *Reconciler) listGatewaysForGatewayClass(ctx context.Context, obj client
return
}

func (r *Reconciler) listGatewaysForGatewayConfig(ctx context.Context, obj client.Object) (recs []reconcile.Request) {
func (r *Reconciler) listGatewaysForGatewayConfig(ctx context.Context, obj client.Object) []reconcile.Request {
logger := log.FromContext(ctx)

gatewayConfig, ok := obj.(*operatorv1beta1.GatewayConfiguration)
Expand All @@ -138,7 +138,7 @@ func (r *Reconciler) listGatewaysForGatewayConfig(ctx context.Context, obj clien
"failed to run map funcs",
"expected", "GatewayConfiguration", "found", reflect.TypeOf(obj),
)
return
return nil
}

gatewayClassList := new(gatewayv1.GatewayClassList)
Expand All @@ -148,7 +148,7 @@ func (r *Reconciler) listGatewaysForGatewayConfig(ctx context.Context, obj clien
"failed to run map funcs",
"error", err.Error(),
)
return
return nil
}

matchingGatewayClasses := make(map[string]struct{})
Expand All @@ -168,9 +168,10 @@ func (r *Reconciler) listGatewaysForGatewayConfig(ctx context.Context, obj clien
"failed to run map funcs",
"error", err.Error(),
)
return
return nil
}

var recs []reconcile.Request
for _, gateway := range gatewayList.Items {
if _, ok := matchingGatewayClasses[string(gateway.Spec.GatewayClassName)]; ok {
recs = append(recs, reconcile.Request{
Expand All @@ -181,8 +182,7 @@ func (r *Reconciler) listGatewaysForGatewayConfig(ctx context.Context, obj clien
})
}
}

return
return recs
}

// listReferenceGrantsForGateway is a watch predicate which finds all Gateways mentioned in a From clause for a
Expand Down
5 changes: 2 additions & 3 deletions controller/pkg/secrets/cert.go
Original file line number Diff line number Diff line change
Expand Up @@ -434,8 +434,7 @@ func ensureContainerImageUpdated(container *corev1.Container, imageVersionStr st

imageParts := strings.Split(container.Image, ":")
if len(imageParts) > 3 {
err = fmt.Errorf("invalid container image found: %s", container.Image)
return
return false, fmt.Errorf("invalid container image found: %s", container.Image)
}

// This is a special case for registries that specify a non default port,
Expand All @@ -462,5 +461,5 @@ func ensureContainerImageUpdated(container *corev1.Container, imageVersionStr st
updated = true
}

return
return updated, nil
}
Loading