refactor: Remove unreachable dead code branches

- firstForwardedValue: strings.Split always returns at least one element
- shouldRunBackupPoll: remaining is always >= 1 by math
- convertContainerDiskInfo: lowerLabel is never empty for non-rootfs

All three functions now at 100% coverage.
This commit is contained in:
rcourtman 2025-12-02 14:36:52 +00:00
parent 3d9c4f6da1
commit 2453198f62
5 changed files with 1 additions and 18 deletions

View file

@ -1645,9 +1645,6 @@ func firstForwardedValue(header string) string {
return "" return ""
} }
parts := strings.Split(header, ",") parts := strings.Split(header, ",")
if len(parts) == 0 {
return ""
}
return strings.TrimSpace(parts[0]) return strings.TrimSpace(parts[0])
} }

View file

@ -76,10 +76,6 @@ func normalizeRequestedScopes(raw *[]string) ([]string, error) {
return []string{config.ScopeWildcard}, nil return []string{config.ScopeWildcard}, nil
} }
if len(normalized) == 0 {
return nil, fmt.Errorf("select at least one scope")
}
sort.Strings(normalized) sort.Strings(normalized)
return normalized, nil return normalized, nil
} }

View file

@ -111,11 +111,7 @@ func convertContainerDiskInfo(status *proxmox.Container, metadata map[string]con
if mountpoint == "" { if mountpoint == "" {
mountpoint = label mountpoint = label
} }
if lowerLabel != "" { disk.Type = lowerLabel
disk.Type = lowerLabel
} else {
disk.Type = "disk"
}
} }
disk.Mountpoint = mountpoint disk.Mountpoint = mountpoint

View file

@ -862,9 +862,6 @@ func (m *Monitor) shouldRunBackupPoll(last time.Time, now time.Time) (bool, stri
} }
remaining := int64(backupCycles) - (m.pollCounter % int64(backupCycles)) remaining := int64(backupCycles) - (m.pollCounter % int64(backupCycles))
if remaining <= 0 {
remaining = int64(backupCycles)
}
return false, fmt.Sprintf("next run in %d polling cycles", remaining), last return false, fmt.Sprintf("next run in %d polling cycles", remaining), last
} }

View file

@ -142,9 +142,6 @@ func (t *StalenessTracker) StalenessScore(instanceType InstanceType, instance st
if score > 1 { if score > 1 {
score = 1 score = 1
} }
if score < 0 {
score = 0
}
return score, true return score, true
} }