From 8aee5ff3da9b566292c599c95852741771aa9171 Mon Sep 17 00:00:00 2001 From: Adam Chalkley Date: Fri, 25 Oct 2024 07:20:43 -0500 Subject: [PATCH] Minor refactoring of ParseRangeString func Swap separate if statements for switch statement to reduce gocognit linter score. Overall this doesn't do much, but an upside is that it does group prefix checks in one place. --- range.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/range.go b/range.go index 76d5879..e91779b 100644 --- a/range.go +++ b/range.go @@ -97,17 +97,17 @@ func ParseRangeString(input string) *Range { return nil } + switch { // Invert the range. // // i.e. @10:20 means ≥ 10 and ≤ 20 (inside the range of {10 .. 20} // inclusive) - if strings.HasPrefix(input, "@") { + case strings.HasPrefix(input, "@"): r.AlertOn = "INSIDE" input = input[1:] - } // ~ represents infinity - if strings.HasPrefix(input, "~") { + case strings.HasPrefix(input, "~"): r.StartInfinity = true input = input[1:] }