Skip to content

Commit ee58e79

Browse files
authored
Merge pull request kubernetes#134812 from skitt/enable-gocritic-unlambda
Avoid no-change lambdas
2 parents 6652c9f + 1e2817d commit ee58e79

File tree

9 files changed

+7
-15
lines changed

9 files changed

+7
-15
lines changed

hack/golangci.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,6 @@ linters:
420420
- sloppyLen
421421
- typeSwitchVar
422422
- underef
423-
- unlambda
424423
- unslice
425424
- valSwap
426425
revive:

hack/golangci.yaml.in

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,6 @@ linters:
249249
- sloppyLen
250250
- typeSwitchVar
251251
- underef
252-
- unlambda
253252
- unslice
254253
- valSwap
255254
{{- end}}

pkg/controller/deployment/progress.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ func (dc *DeploymentController) getReplicaFailures(allRSs []*apps.ReplicaSet, ne
152152
}
153153

154154
// used for unit testing
155-
var nowFn = func() time.Time { return time.Now() }
155+
var nowFn = time.Now
156156

157157
// requeueStuckDeployment checks whether the provided deployment needs to be synced for a progress
158158
// check. It returns the time after the deployment will be requeued for the progress check, 0 if it

pkg/controller/deployment/util/deployment_util.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -766,7 +766,7 @@ func DeploymentProgressing(deployment *apps.Deployment, newStatus *apps.Deployme
766766
}
767767

768768
// used for unit testing
769-
var nowFn = func() time.Time { return time.Now() }
769+
var nowFn = time.Now
770770

771771
// DeploymentTimedOut considers a deployment to have timed out once its condition that reports progress
772772
// is older than progressDeadlineSeconds or a Progressing condition with a TimedOutReason reason already

pkg/kubelet/kuberuntime/kuberuntime_container_linux.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -415,9 +415,7 @@ func toKubeContainerResources(statusResources *runtimeapi.ContainerResources) *k
415415
// Note: this function variable is being added here so it would be possible to mock
416416
// the cgroup version for unit tests by assigning a new mocked function into it. Without it,
417417
// the cgroup version would solely depend on the environment running the test.
418-
var isCgroup2UnifiedMode = func() bool {
419-
return libcontainercgroups.IsCgroup2UnifiedMode()
420-
}
418+
var isCgroup2UnifiedMode = libcontainercgroups.IsCgroup2UnifiedMode
421419

422420
// checkSwapControllerAvailability checks if swap controller is available.
423421
// It returns true if the swap controller is available, false otherwise.

staging/src/k8s.io/apiserver/pkg/cel/openapi/resolver/definitions.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,7 @@ type DefinitionsSchemaResolver struct {
4040
func NewDefinitionsSchemaResolver(getDefinitions common.GetOpenAPIDefinitions, schemes ...*runtime.Scheme) *DefinitionsSchemaResolver {
4141
gvkToRef := make(map[schema.GroupVersionKind]string)
4242
namer := openapi.NewDefinitionNamer(schemes...)
43-
defs := getDefinitions(func(path string) spec.Ref {
44-
return spec.MustCreateRef(path)
45-
})
43+
defs := getDefinitions(spec.MustCreateRef)
4644
for name := range defs {
4745
_, e := namer.GetDefinitionName(name)
4846
gvks := extensionsToGVKs(e)

staging/src/k8s.io/apiserver/pkg/registry/rest/meta.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import (
2424
)
2525

2626
// metav1Now returns metav1.Now(), but allows override for unit testing
27-
var metav1Now = func() metav1.Time { return metav1.Now() }
27+
var metav1Now = metav1.Now
2828

2929
// WipeObjectMetaSystemFields erases fields that are managed by the system on ObjectMeta.
3030
func WipeObjectMetaSystemFields(meta metav1.Object) {

staging/src/k8s.io/component-base/logs/logreduction/logreduction.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import (
2121
"time"
2222
)
2323

24-
var nowfunc = func() time.Time { return time.Now() }
24+
var nowfunc = time.Now
2525

2626
// LogReduction provides a filter for consecutive identical log messages;
2727
// a message will be printed no more than once per interval.

staging/src/k8s.io/kubectl/pkg/explain/v2/funcs.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,7 @@ func WithBuiltinTemplateFuncs(tmpl *template.Template) *template.Template {
6464
}
6565
return buf.String(), nil
6666
},
67-
"split": func(s string, sep string) []string {
68-
return strings.Split(s, sep)
69-
},
67+
"split": strings.Split,
7068
"join": func(sep string, strs ...string) string {
7169
return strings.Join(strs, sep)
7270
},

0 commit comments

Comments
 (0)