chore: enable var-declaration from revive (#8636)

Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
pull/8642/head
Matthieu MOREL 2025-01-22 21:56:44 +01:00 committed by GitHub
parent a9031eb13f
commit 1e54f1cb15
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
18 changed files with 21 additions and 26 deletions

View File

@ -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

View File

@ -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
@ -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
@ -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
@ -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:

View File

@ -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()
}

View File

@ -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)
@ -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)

View File

@ -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
}

View File

@ -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{

View File

@ -1,3 +1,3 @@
package cmd
var TRUE string = "true"
var TRUE = "true"

View File

@ -1,4 +1,4 @@
package test
var VeleroNameSpace string = "velero-test"
var CaptureFlag string = "CAPTRUE-OUTPUT"
var VeleroNameSpace = "velero-test"
var CaptureFlag = "CAPTRUE-OUTPUT"

View File

@ -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")

View File

@ -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")

View File

@ -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)

View File

@ -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)

View File

@ -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...)

View File

@ -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...)

View File

@ -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
}

View File

@ -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{}

View File

@ -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 {

View File

@ -16,6 +16,6 @@ limitations under the License.
package util
var ThirdPartyLabels []string = []string{
var ThirdPartyLabels = []string{
"azure.workload.identity/use",
}