Skip to content

Commit e407e8e

Browse files
committed
fix QF1001 rule from staticcheck
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
1 parent d2c6b6b commit e407e8e

File tree

3 files changed

+8
-9
lines changed

3 files changed

+8
-9
lines changed

.golangci.yaml

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -249,13 +249,12 @@ linters:
249249
staticcheck:
250250
checks:
251251
- all
252-
- -QF1001 # FIXME
253-
- -QF1003 # FIXME
254-
- -QF1004 # FIXME
255-
- -QF1007 # FIXME
256-
- -QF1008 # FIXME
257-
- -QF1009 # FIXME
258-
- -QF1012 # FIXME
252+
- -QF1003 # Convert if/else-if chain to tagged switch
253+
- -QF1004 # Use strings.ReplaceAll instead of strings.Replace with n == -1
254+
- -QF1007 # Merge conditional assignment into variable declaration
255+
- -QF1008 # Omit embedded fields from selector expression
256+
- -QF1009 # Use time.Time.Equal instead of == operator
257+
- -QF1012 # Use fmt.Fprintf(x, ...) instead of x.Write(fmt.Sprintf(...))
259258

260259
testifylint:
261260
# TODO: enable them all

pkg/controller/backup_sync_controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ func (b *backupSyncReconciler) deleteOrphanedBackups(ctx context.Context, locati
353353

354354
for i, backup := range backupList.Items {
355355
log = log.WithField("backup", backup.Name)
356-
if !(backup.Status.Phase == velerov1api.BackupPhaseCompleted || backup.Status.Phase == velerov1api.BackupPhasePartiallyFailed) || backupStoreBackups.Has(backup.Name) {
356+
if !(backup.Status.Phase != velerov1api.BackupPhaseCompleted || backup.Status.Phase == velerov1api.BackupPhasePartiallyFailed) || backupStoreBackups.Has(backup.Name) {
357357
continue
358358
}
359359

pkg/uploader/kopia/snapshot.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ func reportSnapshotStatus(manifest *snapshot.Manifest, policyTree *policy.Tree)
314314
break
315315
}
316316
policy := policyTree.EffectivePolicy()
317-
if !(policy != nil && bool(*policy.ErrorHandlingPolicy.IgnoreUnknownTypes) && strings.Contains(ent.Error, fs.ErrUnknown.Error())) {
317+
if !(policy == nil || !bool(*policy.ErrorHandlingPolicy.IgnoreUnknownTypes) || !strings.Contains(ent.Error, fs.ErrUnknown.Error()) {
318318
errs = append(errs, fmt.Sprintf("Error when processing %v: %v", ent.EntryPath, ent.Error))
319319
}
320320
}

0 commit comments

Comments
 (0)