refactor: Remove unreachable dead code branches

- errors.isRetryable: Convert final case to default (all ErrorType values covered)
- scheduler.SelectInterval: Remove bounds checks after mathematical computation
  that guarantees target ∈ [min, max]

Both functions now at 100% coverage.
This commit is contained in:
rcourtman
2025-12-02 14:48:57 +00:00
parent 158669296e
commit b6ae5d5e24
2 changed files with 2 additions and 9 deletions

View File

@@ -116,14 +116,13 @@ func isRetryable(errorType ErrorType, err error) bool {
return true
case ErrorTypeAuth, ErrorTypeValidation, ErrorTypeNotFound:
return false
case ErrorTypeInternal, ErrorTypeAPI:
default: // ErrorTypeInternal, ErrorTypeAPI
// Check the underlying error
if err != nil {
return !errors.Is(err, ErrInvalidInput) && !errors.Is(err, ErrForbidden)
}
return true
}
return false
}
// Helper functions

View File

@@ -305,15 +305,9 @@ func (a *adaptiveIntervalSelector) SelectInterval(req IntervalRequest) time.Dura
score := clampFloat(req.StalenessScore, 0, 1)
span := float64(max - min)
// target is mathematically in [min, max] since score ∈ [0,1] and span >= 0
target := time.Duration(float64(min) + span*(1-score))
if target < min {
target = min
}
if target > max {
target = max
}
if req.ErrorCount > 0 {
penalty := 1 + a.errorPenalty*float64(req.ErrorCount)
if penalty > 0 {