Skip to content

Commit 953a89e

Browse files
committed
Fix bug introduced int:"linter: all 'switch' related issues"
This fixes a bug introduced in: 2f9c4cd. For the `moving*` functions, default was to return `r` and not `nil`
1 parent 36302cb commit 953a89e

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

pkg/parser/parser.go

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,9 @@ func (e *expr) ToString() string {
5252
s = strings.Replace(s, `\`, `\\`, -1)
5353
s = strings.Replace(s, `'`, `\'`, -1)
5454
return "'" + s + "'"
55-
case EtName:
56-
return fmt.Sprint(e.target)
55+
default:
56+
return e.target
5757
}
58-
59-
return e.target
6058
}
6159

6260
func (e *expr) SetTarget(target string) {
@@ -173,17 +171,14 @@ func (e *expr) Metrics() []MetricRequest {
173171
r[i].From -= 7 * 86400 // starts -7 days from where the original starts
174172
}
175173
case "movingAverage", "movingMedian", "movingMin", "movingMax", "movingSum":
176-
switch e.args[1].etype {
177-
case EtString:
174+
if e.args[1].etype == EtString {
178175
offs, err := e.GetIntervalArg(1, 1)
179176
if err != nil {
180177
return nil
181178
}
182179
for i := range r {
183180
r[i].From -= offs
184181
}
185-
default:
186-
return nil
187182
}
188183
}
189184
return r

0 commit comments

Comments
 (0)