-
Notifications
You must be signed in to change notification settings - Fork 26
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
Simplify if else statements #222
Simplify if else statements #222
Conversation
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: bshephar The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
d89e672
to
af17297
Compare
/test functional Is this a consistent failure ? |
Hmm yeah, this is reproducing locally as well actually. |
af17297
to
1dc9165
Compare
Interesting, seems to be this one:
There's a diff in ctrlResult vs ctrl.Result{}:
But not sure just yet as to why it would make a difference in the consolidated if this or this, vs the two seperate if statements. It's exactly the same except it doesn't go on for as long when I do the same thing with seperate if statements:
Maybe some timing thing? |
It looks you returned |
/test heat-operator-build-deploy-kuttl |
If we're returning from a if statement, we really don't need an else. These can be simplified and made more legible by simply removing the else and having a seperate if block. Signed-off-by: Brendan Shephard <bshephar@redhat.com>
1dc9165
to
e0defb1
Compare
@@ -336,7 +337,7 @@ func (r *HeatCfnAPIReconciler) reconcileInit( | |||
|
|||
ksSvcObj := keystonev1.NewKeystoneService(ksSvcSpec, instance.Namespace, serviceLabels, time.Duration(10)*time.Second) | |||
ctrlResult, err = ksSvcObj.CreateOrPatch(ctx, helper) | |||
if err != nil { | |||
if err != nil || (ctrlResult != ctrl.Result{}) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought we'd need this logic kept after condition mirror but it turned out this method returns non-emptry ctrlResult only when KeystoneService is not found... so skipping the condition mirror makes more sense.
/test heat-operator-build-deploy-kuttl |
/lgtm |
f3690dc
into
openstack-k8s-operators:main
If we're returning from a if statement, we really don't need an else. These can be simplified and made more legible by simply removing the else and having a seperate if block.
This is really just a quality of life patch. IMO, the use of
else
can often make code a bit harder to follow and read.If this is just something we're doing for consistency with the wider org's sake, I'm happy to raise it to the wider group for broader perspective. But at least here, I think it makes things a little nicer to read and follow.