Skip to content

Commit 5878458

Browse files
authored
Merge pull request #2464 from mrueg/avoid-naked-return
chore: Avoid naked return
2 parents d1e7179 + cc79a58 commit 5878458

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

pkg/watch/watch.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -74,31 +74,31 @@ func NewInstrumentedListerWatcher(lw cache.ListerWatcher, metrics *ListWatchMetr
7474

7575
// List is a wrapper func around the cache.ListerWatcher.List func. It increases the success/error
7676
// / counters based on the outcome of the List operation it instruments.
77-
func (i *InstrumentedListerWatcher) List(options metav1.ListOptions) (res runtime.Object, err error) {
77+
func (i *InstrumentedListerWatcher) List(options metav1.ListOptions) (runtime.Object, error) {
7878

7979
if i.useAPIServerCache {
8080
options.ResourceVersion = "0"
8181
}
8282

83-
res, err = i.lw.List(options)
83+
res, err := i.lw.List(options)
8484
if err != nil {
8585
i.metrics.ListTotal.WithLabelValues("error", i.resource).Inc()
86-
return
86+
return nil, err
8787
}
8888

8989
i.metrics.ListTotal.WithLabelValues("success", i.resource).Inc()
90-
return
90+
return res, nil
9191
}
9292

9393
// Watch is a wrapper func around the cache.ListerWatcher.Watch func. It increases the success/error
9494
// counters based on the outcome of the Watch operation it instruments.
95-
func (i *InstrumentedListerWatcher) Watch(options metav1.ListOptions) (res watch.Interface, err error) {
96-
res, err = i.lw.Watch(options)
95+
func (i *InstrumentedListerWatcher) Watch(options metav1.ListOptions) (watch.Interface, error) {
96+
res, err := i.lw.Watch(options)
9797
if err != nil {
9898
i.metrics.WatchTotal.WithLabelValues("error", i.resource).Inc()
99-
return
99+
return nil, err
100100
}
101101

102102
i.metrics.WatchTotal.WithLabelValues("success", i.resource).Inc()
103-
return
103+
return res, nil
104104
}

0 commit comments

Comments
 (0)