Skip to content

Commit 10f36f0

Browse files
committed
Enable additional linters and metalinter checks. Fix findings
Enable new linters: asasalint, bidichk, dupword Enable gocritic checks: diagnostic, experimental, performance
1 parent 03938e4 commit 10f36f0

File tree

3 files changed

+27
-4
lines changed

3 files changed

+27
-4
lines changed

.golangci.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
linters:
22
disable-all: true
33
enable:
4+
- asasalint
45
- asciicheck
6+
- bidichk
57
- bodyclose
68
- cyclop
79
- depguard
810
- dogsled
11+
- dupword
912
- durationcheck
1013
- errcheck
1114
- exportloopref
@@ -54,6 +57,27 @@ linters-settings:
5457
max-complexity: 30
5558
gci:
5659
local-prefixes: sigs.k8s.io/cluster-api-provider-openstack
60+
gocritic:
61+
enabled-tags:
62+
- diagnostic
63+
- experimental
64+
- performance
65+
disabled-checks:
66+
- appendAssign
67+
- dupImport # https://github.com/go-critic/go-critic/issues/845
68+
- evalOrder
69+
- ifElseChain
70+
- octalLiteral
71+
- regexpSimplify
72+
- sloppyReassign
73+
- truncateCmp
74+
- typeDefFirst
75+
- unnamedResult
76+
- unnecessaryDefer
77+
- whyNoLint
78+
- wrapperFunc
79+
- rangeValCopy
80+
- hugeParam
5781
importas:
5882
no-unaliased: true
5983
alias:

controllers/openstackmachine_controller.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ func (r *OpenStackMachineReconciler) reconcileNormal(ctx context.Context, scope
421421
return ctrl.Result{}, nil
422422
}
423423

424-
if len(fp.PortID) != 0 {
424+
if fp.PortID != "" {
425425
scope.Logger.Info("Floating IP already associated to a port:", "id", fp.ID, "fixed ip", fp.FixedIP, "portID", port.ID)
426426
} else {
427427
err = networkingService.AssociateFloatingIP(openStackMachine, fp, port.ID)
@@ -538,7 +538,7 @@ func handleUpdateMachineError(logger logr.Logger, openstackMachine *infrav1.Open
538538
openstackMachine.Status.FailureReason = &err
539539
openstackMachine.Status.FailureMessage = pointer.StringPtr(message.Error())
540540
// TODO remove if this error is logged redundantly
541-
logger.Error(fmt.Errorf(string(err)), message.Error())
541+
logger.Error(fmt.Errorf("%s", string(err)), message.Error())
542542
}
543543

544544
func (r *OpenStackMachineReconciler) reconcileLoadBalancerMember(scope *scope.Scope, openStackCluster *infrav1.OpenStackCluster, machine *clusterv1.Machine, openStackMachine *infrav1.OpenStackMachine, instanceNS *compute.InstanceNetworkStatus, clusterName string) error {

test/e2e/shared/context.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ func NewE2EContext(options ...Option) *E2EContext {
3737
ctx := &E2EContext{}
3838
ctx.Environment.Scheme = DefaultScheme()
3939
ctx.Environment.Namespaces = map[*corev1.Namespace]context.CancelFunc{}
40-
// ctx.Lifecycle = DefaultGinkgoLifecycle()
4140

4241
for _, opt := range options {
4342
opt(ctx)
@@ -82,7 +81,7 @@ type Settings struct {
8281

8382
// RuntimeEnvironment represents the runtime environment of the test.
8483
type RuntimeEnvironment struct {
85-
// BootstrapClusterProvider manages provisioning of the the bootstrap cluster to be used for the e2e tests.
84+
// BootstrapClusterProvider manages provisioning of the bootstrap cluster to be used for the e2e tests.
8685
// Please note that provisioning will be skipped if use-existing-cluster is provided.
8786
BootstrapClusterProvider bootstrap.ClusterProvider
8887
// BootstrapClusterProxy allows to interact with the bootstrap cluster to be used for the e2e tests.

0 commit comments

Comments
 (0)