From b6ae5d5e246ab20dd11d05130fe17594347c3563 Mon Sep 17 00:00:00 2001 From: rcourtman Date: Tue, 2 Dec 2025 14:48:57 +0000 Subject: [PATCH] refactor: Remove unreachable dead code branches MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 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. --- internal/errors/errors.go | 3 +-- internal/monitoring/scheduler.go | 8 +------- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/internal/errors/errors.go b/internal/errors/errors.go index d336b050f..60b56b8b5 100644 --- a/internal/errors/errors.go +++ b/internal/errors/errors.go @@ -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 diff --git a/internal/monitoring/scheduler.go b/internal/monitoring/scheduler.go index 129c0080b..16d4b466e 100644 --- a/internal/monitoring/scheduler.go +++ b/internal/monitoring/scheduler.go @@ -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 {