Skip to content

Commit

Permalink
Enable additional linters and metalinter checks. Fix findings
Browse files Browse the repository at this point in the history
Enable new linters: asasalint, bidichk, dupword
Enable gocritic checks: diagnostic, experimental, performance
  • Loading branch information
oscr committed Oct 17, 2022
1 parent 03938e4 commit 10f36f0
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 4 deletions.
24 changes: 24 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
linters:
disable-all: true
enable:
- asasalint
- asciicheck
- bidichk
- bodyclose
- cyclop
- depguard
- dogsled
- dupword
- durationcheck
- errcheck
- exportloopref
Expand Down Expand Up @@ -54,6 +57,27 @@ linters-settings:
max-complexity: 30
gci:
local-prefixes: sigs.k8s.io/cluster-api-provider-openstack
gocritic:
enabled-tags:
- diagnostic
- experimental
- performance
disabled-checks:
- appendAssign
- dupImport # https://github.com/go-critic/go-critic/issues/845
- evalOrder
- ifElseChain
- octalLiteral
- regexpSimplify
- sloppyReassign
- truncateCmp
- typeDefFirst
- unnamedResult
- unnecessaryDefer
- whyNoLint
- wrapperFunc
- rangeValCopy
- hugeParam
importas:
no-unaliased: true
alias:
Expand Down
4 changes: 2 additions & 2 deletions controllers/openstackmachine_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ func (r *OpenStackMachineReconciler) reconcileNormal(ctx context.Context, scope
return ctrl.Result{}, nil
}

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

func (r *OpenStackMachineReconciler) reconcileLoadBalancerMember(scope *scope.Scope, openStackCluster *infrav1.OpenStackCluster, machine *clusterv1.Machine, openStackMachine *infrav1.OpenStackMachine, instanceNS *compute.InstanceNetworkStatus, clusterName string) error {
Expand Down
3 changes: 1 addition & 2 deletions test/e2e/shared/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ func NewE2EContext(options ...Option) *E2EContext {
ctx := &E2EContext{}
ctx.Environment.Scheme = DefaultScheme()
ctx.Environment.Namespaces = map[*corev1.Namespace]context.CancelFunc{}
// ctx.Lifecycle = DefaultGinkgoLifecycle()

for _, opt := range options {
opt(ctx)
Expand Down Expand Up @@ -82,7 +81,7 @@ type Settings struct {

// RuntimeEnvironment represents the runtime environment of the test.
type RuntimeEnvironment struct {
// BootstrapClusterProvider manages provisioning of the the bootstrap cluster to be used for the e2e tests.
// BootstrapClusterProvider manages provisioning of the bootstrap cluster to be used for the e2e tests.
// Please note that provisioning will be skipped if use-existing-cluster is provided.
BootstrapClusterProvider bootstrap.ClusterProvider
// BootstrapClusterProxy allows to interact with the bootstrap cluster to be used for the e2e tests.
Expand Down

0 comments on commit 10f36f0

Please sign in to comment.