Skip to content

Commit b155eb3

Browse files
committed
Enable more gocritic diagnostic and performance linters
1 parent a86df71 commit b155eb3

File tree

7 files changed

+26
-13
lines changed

7 files changed

+26
-13
lines changed

.golangci.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,9 @@ linters-settings:
150150
- G108 # Profiling endpoint is automatically exposed on /debug/pprof
151151
gocritic:
152152
enabled-tags:
153+
- diagnostic
153154
- experimental
155+
- performance
154156
disabled-checks:
155157
- appendAssign
156158
- dupImport # https://github.com/go-critic/go-critic/issues/845
@@ -165,6 +167,8 @@ linters-settings:
165167
- unnecessaryDefer
166168
- whyNoLint
167169
- wrapperFunc
170+
- rangeValCopy
171+
- hugeParam
168172
unused:
169173
go: "1.19"
170174
issues:

exp/internal/controllers/machinepool_controller.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,9 @@ func (r *MachinePoolReconciler) Reconcile(ctx context.Context, req ctrl.Request)
154154
// Patch ObservedGeneration only if the reconciliation completed successfully
155155
patchOpts := []patch.Option{}
156156
if reterr == nil {
157-
patchOpts = append(patchOpts, patch.WithStatusObservedGeneration{})
158-
patchOpts = append(patchOpts,
157+
patchOpts = append(
158+
patchOpts,
159+
patch.WithStatusObservedGeneration{},
159160
patch.WithOwnedConditions{Conditions: []clusterv1.ConditionType{
160161
clusterv1.ReadyCondition,
161162
clusterv1.BootstrapReadyCondition,

internal/controllers/topology/cluster/reconcile_state_test.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -212,12 +212,16 @@ func TestReconcileShim(t *testing.T) {
212212
// Add the shim as a temporary owner for the InfrastructureCluster and ControlPlane.
213213
// Add the cluster as a final owner for the InfrastructureCluster and ControlPlane (reconciled).
214214
ownerRefs := s.Current.InfrastructureCluster.GetOwnerReferences()
215-
ownerRefs = append(ownerRefs, *ownerReferenceTo(cluster1Shim))
216-
ownerRefs = append(ownerRefs, *ownerReferenceTo(cluster1))
215+
ownerRefs = append(
216+
ownerRefs,
217+
*ownerReferenceTo(cluster1Shim),
218+
*ownerReferenceTo(cluster1))
217219
s.Current.InfrastructureCluster.SetOwnerReferences(ownerRefs)
218220
ownerRefs = s.Current.ControlPlane.Object.GetOwnerReferences()
219-
ownerRefs = append(ownerRefs, *ownerReferenceTo(cluster1Shim))
220-
ownerRefs = append(ownerRefs, *ownerReferenceTo(cluster1))
221+
ownerRefs = append(
222+
ownerRefs,
223+
*ownerReferenceTo(cluster1Shim),
224+
*ownerReferenceTo(cluster1))
221225
s.Current.ControlPlane.Object.SetOwnerReferences(ownerRefs)
222226

223227
// Pre-create a shim

test/framework/bootstrap/kind_provider.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,10 @@ func (k *KindClusterProvider) createKindCluster() {
148148
if k.nodeImage != "" {
149149
nodeImage = k.nodeImage
150150
}
151-
kindCreateOptions = append(kindCreateOptions, kind.CreateWithNodeImage(nodeImage))
152-
kindCreateOptions = append(kindCreateOptions, kind.CreateWithRetain(true))
151+
kindCreateOptions = append(
152+
kindCreateOptions,
153+
kind.CreateWithNodeImage(nodeImage),
154+
kind.CreateWithRetain(true))
153155

154156
provider := kind.NewProvider(kind.ProviderWithLogger(cmd.NewLogger()))
155157
err := provider.Create(k.name, kindCreateOptions...)

test/framework/kubetest/run.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -161,10 +161,12 @@ func Run(ctx context.Context, input RunInput) error {
161161
}
162162

163163
// Formulate our command arguments
164-
args := []string{}
164+
var args []string
165165
args = append(args, ginkgoArgs...)
166-
args = append(args, "/usr/local/bin/e2e.test")
167-
args = append(args, "--")
166+
args = append(
167+
args,
168+
"/usr/local/bin/e2e.test",
169+
"--")
168170
args = append(args, e2eArgs...)
169171
args = append(args, config.toFlags()...)
170172

test/infrastructure/docker/exp/internal/docker/nodepool.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ func getBootstrapData(ctx context.Context, c client.Client, machinePool *expv1.M
366366
}
367367

368368
format := s.Data["format"]
369-
if string(format) == "" {
369+
if len(format) == 0 {
370370
format = []byte(bootstrapv1.CloudConfig)
371371
}
372372

test/infrastructure/docker/internal/controllers/dockermachine_controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,7 @@ func (r *DockerMachineReconciler) getBootstrapData(ctx context.Context, machine
452452
}
453453

454454
format := s.Data["format"]
455-
if string(format) == "" {
455+
if len(format) == 0 {
456456
format = []byte(bootstrapv1.CloudConfig)
457457
}
458458

0 commit comments

Comments
 (0)