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 2453198f62
commit c1d98e6aa8
2 changed files with 2 additions and 9 deletions

View file

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

View file

@ -305,15 +305,9 @@ func (a *adaptiveIntervalSelector) SelectInterval(req IntervalRequest) time.Dura
score := clampFloat(req.StalenessScore, 0, 1) score := clampFloat(req.StalenessScore, 0, 1)
span := float64(max - min) 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)) target := time.Duration(float64(min) + span*(1-score))
if target < min {
target = min
}
if target > max {
target = max
}
if req.ErrorCount > 0 { if req.ErrorCount > 0 {
penalty := 1 + a.errorPenalty*float64(req.ErrorCount) penalty := 1 + a.errorPenalty*float64(req.ErrorCount)
if penalty > 0 { if penalty > 0 {