Browse Source

promql: apply golint suggestions (#5066)

Signed-off-by: Matt Layher <mdlayher@gmail.com>
pull/5087/head
Matt Layher 6 years ago committed by Brian Brazil
parent
commit
43c9d9e91f
  1. 6
      promql/ast.go
  2. 10
      promql/engine.go
  3. 4
      promql/test.go

6
promql/ast.go

@ -306,11 +306,11 @@ func Walk(v Visitor, node Node, path []Node) error {
type inspector func(Node, []Node) error
func (f inspector) Visit(node Node, path []Node) (Visitor, error) {
if err := f(node, path); err == nil {
return f, nil
} else {
if err := f(node, path); err != nil {
return nil, err
}
return f, nil
}
// Inspect traverses an AST in depth-first order: It starts by calling

10
promql/engine.go

@ -614,7 +614,7 @@ func extractFuncFromPath(p []Node) string {
return extractFuncFromPath(p[:len(p)-1])
}
func checkForSeriesSetExpansion(expr Expr, ctx context.Context) error {
func checkForSeriesSetExpansion(ctx context.Context, expr Expr) error {
switch e := expr.(type) {
case *MatrixSelector:
if e.series == nil {
@ -966,7 +966,7 @@ func (ev *evaluator) eval(expr Expr) Value {
}
sel := e.Args[matrixArgIndex].(*MatrixSelector)
if err := checkForSeriesSetExpansion(sel, ev.ctx); err != nil {
if err := checkForSeriesSetExpansion(ev.ctx, sel); err != nil {
ev.error(err)
}
mat := make(Matrix, 0, len(sel.series)) // Output matrix.
@ -1100,7 +1100,7 @@ func (ev *evaluator) eval(expr Expr) Value {
})
case *VectorSelector:
if err := checkForSeriesSetExpansion(e, ev.ctx); err != nil {
if err := checkForSeriesSetExpansion(ev.ctx, e); err != nil {
ev.error(err)
}
mat := make(Matrix, 0, len(e.series))
@ -1175,7 +1175,7 @@ func durationToInt64Millis(d time.Duration) int64 {
// vectorSelector evaluates a *VectorSelector expression.
func (ev *evaluator) vectorSelector(node *VectorSelector, ts int64) Vector {
if err := checkForSeriesSetExpansion(node, ev.ctx); err != nil {
if err := checkForSeriesSetExpansion(ev.ctx, node); err != nil {
ev.error(err)
}
@ -1249,7 +1249,7 @@ func putPointSlice(p []Point) {
// matrixSelector evaluates a *MatrixSelector expression.
func (ev *evaluator) matrixSelector(node *MatrixSelector) Matrix {
if err := checkForSeriesSetExpansion(node, ev.ctx); err != nil {
if err := checkForSeriesSetExpansion(ev.ctx, node); err != nil {
ev.error(err)
}

4
promql/test.go

@ -606,9 +606,9 @@ func (ll *LazyLoader) parse(input string) error {
}
ll.loadCmd = cmd
return nil
} else {
return raise(i, "invalid command %q", l)
}
return raise(i, "invalid command %q", l)
}
return errors.New("no \"load\" command found")
}

Loading…
Cancel
Save