Skip to content

Commit

Permalink
chore: enable var-declaration from revive (#8636)
Browse files Browse the repository at this point in the history
Signed-off-by: Matthieu MOREL <[email protected]>
  • Loading branch information
mmorel-35 authored Jan 22, 2025
1 parent a9031eb commit 1e54f1c
Show file tree
Hide file tree
Showing 18 changed files with 21 additions and 26 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pr-codespell.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- name: Codespell
uses: codespell-project/actions-codespell@master
with:
# ignore the config/.../crd.go file as it's generated binary data that is edited elswhere.
# ignore the config/.../crd.go file as it's generated binary data that is edited elsewhere.
skip: .git,*.png,*.jpg,*.woff,*.ttf,*.gif,*.ico,./config/crd/v1beta1/crds/crds.go,./config/crd/v1/crds/crds.go,./config/crd/v2alpha1/crds/crds.go,./go.sum,./LICENSE
ignore_words_list: iam,aks,ist,bridget,ue,shouldnot,atleast,notin,sme,optin
check_filenames: true
Expand Down
7 changes: 1 addition & 6 deletions .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,6 @@ linters-settings:
- name: context-as-argument
disabled: true
- name: context-keys-type
disabled: false
- name: dot-imports
disabled: true
- name: early-return
Expand All @@ -262,7 +261,6 @@ linters-settings:
- name: indent-error-flow
disabled: true
- name: range
disabled: false
- name: receiver-naming
disabled: true
- name: redefines-builtin-id
Expand All @@ -272,19 +270,16 @@ linters-settings:
arguments:
- "preserveScope"
- name: time-naming
disabled: false
- name: unexported-return
disabled: true
- name: unnecessary-stmt
disabled: true
- name: unreachable-code
disabled: false
- name: unused-parameter
disabled: true
- name: use-any
disabled: true
- name: var-declaration
disabled: true
- name: var-naming
disabled: true

Expand Down Expand Up @@ -333,7 +328,7 @@ linters-settings:
force-case-trailing-whitespace: 0
# Force cuddling of err checks with err var assignment
force-err-cuddling: false
# Allow leading comments to be separated with empty liens
# Allow leading comments to be separated with empty lines
allow-separated-leading-comment: false

linters:
Expand Down
2 changes: 1 addition & 1 deletion internal/volume/volumes_information.go
Original file line number Diff line number Diff line change
Expand Up @@ -830,7 +830,7 @@ func (t *RestoreVolumeInfoTracker) Result() []*RestoreVolumeInfo {
continue
}
pvcNS, pvcName := n[0], n[1]
var restoreSize int64 = 0
var restoreSize int64
if csiSnapshot.Status != nil && csiSnapshot.Status.RestoreSize != nil {
restoreSize = csiSnapshot.Status.RestoreSize.Value()
}
Expand Down
4 changes: 2 additions & 2 deletions internal/volumehelper/volume_policy_helper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ func TestVolumeHelperImpl_ShouldPerformSnapshot(t *testing.T) {
fakeClient.Create(context.Background(), tc.pod)
}

var p *resourcepolicies.Policies = nil
var p *resourcepolicies.Policies
if tc.resourcePolicies != nil {
p = &resourcepolicies.Policies{}
err := p.BuildPolicy(tc.resourcePolicies)
Expand Down Expand Up @@ -679,7 +679,7 @@ func TestVolumeHelperImpl_ShouldPerformFSBackup(t *testing.T) {
fakeClient.Create(context.Background(), tc.pod)
}

var p *resourcepolicies.Policies = nil
var p *resourcepolicies.Policies
if tc.resourcePolicies != nil {
p = &resourcepolicies.Policies{}
err := p.BuildPolicy(tc.resourcePolicies)
Expand Down
2 changes: 1 addition & 1 deletion pkg/backup/backup.go
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ func (kb *kubernetesBackupper) BackupWithResolvers(
}
backupRequest.Status.Progress = &velerov1api.BackupProgress{TotalItems: len(items)}

var resourcePolicy *resourcepolicies.Policies = nil
var resourcePolicy *resourcepolicies.Policies
if backupRequest.ResPolicies != nil {
resourcePolicy = backupRequest.ResPolicies
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/cmd/cli/restore/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ func (o *CreateOptions) Run(c *cobra.Command, f client.Factory) error {
}
}

var resModifiers *corev1.TypedLocalObjectReference = nil
var resModifiers *corev1.TypedLocalObjectReference

if o.ResourceModifierConfigMap != "" {
resModifiers = &corev1.TypedLocalObjectReference{
Expand Down
2 changes: 1 addition & 1 deletion pkg/cmd/const.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
package cmd

var TRUE string = "true"
var TRUE = "true"
4 changes: 2 additions & 2 deletions pkg/cmd/test/const.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package test

var VeleroNameSpace string = "velero-test"
var CaptureFlag string = "CAPTRUE-OUTPUT"
var VeleroNameSpace = "velero-test"
var CaptureFlag = "CAPTRUE-OUTPUT"
2 changes: 1 addition & 1 deletion pkg/controller/data_download_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func dataDownloadBuilder() *builder.DataDownloadBuilder {
}

func initDataDownloadReconciler(objects []runtime.Object, needError ...bool) (*DataDownloadReconciler, error) {
var errs []error = make([]error, 6)
var errs = make([]error, 6)
for k, isError := range needError {
if k == 0 && isError {
errs[0] = fmt.Errorf("Get error")
Expand Down
2 changes: 1 addition & 1 deletion pkg/controller/data_upload_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ func (c *FakeClient) List(ctx context.Context, list kbclient.ObjectList, opts ..
}

func initDataUploaderReconciler(needError ...bool) (*DataUploadReconciler, error) {
var errs []error = make([]error, 6)
var errs = make([]error, 6)
for k, isError := range needError {
if k == 0 && isError {
errs[0] = fmt.Errorf("Get error")
Expand Down
2 changes: 1 addition & 1 deletion pkg/controller/restore_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ func (r *restoreReconciler) validateAndComplete(restore *api.Restore) (backupInf
restore.Spec.ScheduleName = info.backup.GetLabels()[api.ScheduleNameLabel]
}

var resourceModifiers *resourcemodifiers.ResourceModifiers = nil
var resourceModifiers *resourcemodifiers.ResourceModifiers
if restore.Spec.ResourceModifier != nil && strings.EqualFold(restore.Spec.ResourceModifier.Kind, resourcemodifiers.ConfigmapRefType) {
ResourceModifierConfigMap := &corev1api.ConfigMap{}
err := r.kbClient.Get(context.Background(), client.ObjectKey{Namespace: restore.Namespace, Name: restore.Spec.ResourceModifier.Name}, ResourceModifierConfigMap)
Expand Down
2 changes: 1 addition & 1 deletion pkg/datapath/micro_service_watcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ var funcRedirectLog = redirectDataMoverLogs
var funcGetResultFromMessage = getResultFromMessage
var funcGetProgressFromMessage = getProgressFromMessage

var eventWaitTimeout time.Duration = time.Minute
var eventWaitTimeout = time.Minute

func (ms *microServiceBRWatcher) startWatch() {
ms.wgWatcher.Add(1)
Expand Down
2 changes: 1 addition & 1 deletion pkg/exposer/csi_snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,7 @@ func (e *csiSnapshotExposer) createBackupPod(
return nil, errors.Wrap(err, "error to get inherited pod info from node-agent")
}

var gracePeriod int64 = 0
var gracePeriod int64
volumeMounts, volumeDevices, volumePath := kube.MakePodPVCAttachment(volumeName, backupPVC.Spec.VolumeMode, backupPVCReadOnly)
volumeMounts = append(volumeMounts, podInfo.volumeMounts...)

Expand Down
2 changes: 1 addition & 1 deletion pkg/exposer/generic_restore.go
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ func (e *genericRestoreExposer) createRestorePod(ctx context.Context, ownerObjec
return nil, errors.Wrap(err, "error to get inherited pod info from node-agent")
}

var gracePeriod int64 = 0
var gracePeriod int64
volumeMounts, volumeDevices, volumePath := kube.MakePodPVCAttachment(volumeName, targetPVC.Spec.VolumeMode, false)
volumeMounts = append(volumeMounts, podInfo.volumeMounts...)

Expand Down
2 changes: 1 addition & 1 deletion pkg/restore/pv_restorer.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ func (r *pvRestorer) executePVAction(obj *unstructured.Unstructured) (*unstructu
if !ok {
return nil, errors.Errorf("unexpected type %T", updated1)
}
var iops int64 = 0
var iops int64
if snapshotInfo.volumeIOPS != nil {
iops = *snapshotInfo.volumeIOPS
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/util/kube/event.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ func (er *eventRecorder) EndingEvent(object runtime.Object, warning bool, reason
}
}

var shutdownTimeout time.Duration = time.Minute
var shutdownTimeout = time.Minute

func (er *eventRecorder) Shutdown() {
var wait chan struct{}
Expand Down
4 changes: 2 additions & 2 deletions pkg/util/kube/pvc_pv.go
Original file line number Diff line number Diff line change
Expand Up @@ -356,8 +356,8 @@ func IsPVCBound(pvc *corev1api.PersistentVolumeClaim) bool {

// MakePodPVCAttachment returns the volume mounts and devices for a pod needed to attach a PVC
func MakePodPVCAttachment(volumeName string, volumeMode *corev1api.PersistentVolumeMode, readOnly bool) ([]corev1api.VolumeMount, []corev1api.VolumeDevice, string) {
var volumeMounts []corev1api.VolumeMount = nil
var volumeDevices []corev1api.VolumeDevice = nil
var volumeMounts []corev1api.VolumeMount
var volumeDevices []corev1api.VolumeDevice
volumePath := "/" + volumeName

if volumeMode != nil && *volumeMode == corev1api.PersistentVolumeBlock {
Expand Down
2 changes: 1 addition & 1 deletion pkg/util/third_party.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ limitations under the License.

package util

var ThirdPartyLabels []string = []string{
var ThirdPartyLabels = []string{
"azure.workload.identity/use",
}

0 comments on commit 1e54f1c

Please sign in to comment.