mirror of
https://github.com/rcourtman/Pulse.git
synced 2026-02-18 00:17:39 +01:00
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:
@@ -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
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user