mirror of
https://github.com/prometheus/prometheus.git
synced 2024-12-25 21:54:10 -08:00
promql: apply golint suggestions (#5066)
Signed-off-by: Matt Layher <mdlayher@gmail.com>
This commit is contained in:
parent
8cac9cbe1d
commit
43c9d9e91f
|
@ -306,11 +306,11 @@ func Walk(v Visitor, node Node, path []Node) error {
|
||||||
type inspector func(Node, []Node) error
|
type inspector func(Node, []Node) error
|
||||||
|
|
||||||
func (f inspector) Visit(node Node, path []Node) (Visitor, error) {
|
func (f inspector) Visit(node Node, path []Node) (Visitor, error) {
|
||||||
if err := f(node, path); err == nil {
|
if err := f(node, path); err != nil {
|
||||||
return f, nil
|
|
||||||
} else {
|
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return f, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Inspect traverses an AST in depth-first order: It starts by calling
|
// Inspect traverses an AST in depth-first order: It starts by calling
|
||||||
|
|
|
@ -614,7 +614,7 @@ func extractFuncFromPath(p []Node) string {
|
||||||
return extractFuncFromPath(p[:len(p)-1])
|
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) {
|
switch e := expr.(type) {
|
||||||
case *MatrixSelector:
|
case *MatrixSelector:
|
||||||
if e.series == nil {
|
if e.series == nil {
|
||||||
|
@ -966,7 +966,7 @@ func (ev *evaluator) eval(expr Expr) Value {
|
||||||
}
|
}
|
||||||
|
|
||||||
sel := e.Args[matrixArgIndex].(*MatrixSelector)
|
sel := e.Args[matrixArgIndex].(*MatrixSelector)
|
||||||
if err := checkForSeriesSetExpansion(sel, ev.ctx); err != nil {
|
if err := checkForSeriesSetExpansion(ev.ctx, sel); err != nil {
|
||||||
ev.error(err)
|
ev.error(err)
|
||||||
}
|
}
|
||||||
mat := make(Matrix, 0, len(sel.series)) // Output matrix.
|
mat := make(Matrix, 0, len(sel.series)) // Output matrix.
|
||||||
|
@ -1100,7 +1100,7 @@ func (ev *evaluator) eval(expr Expr) Value {
|
||||||
})
|
})
|
||||||
|
|
||||||
case *VectorSelector:
|
case *VectorSelector:
|
||||||
if err := checkForSeriesSetExpansion(e, ev.ctx); err != nil {
|
if err := checkForSeriesSetExpansion(ev.ctx, e); err != nil {
|
||||||
ev.error(err)
|
ev.error(err)
|
||||||
}
|
}
|
||||||
mat := make(Matrix, 0, len(e.series))
|
mat := make(Matrix, 0, len(e.series))
|
||||||
|
@ -1175,7 +1175,7 @@ func durationToInt64Millis(d time.Duration) int64 {
|
||||||
|
|
||||||
// vectorSelector evaluates a *VectorSelector expression.
|
// vectorSelector evaluates a *VectorSelector expression.
|
||||||
func (ev *evaluator) vectorSelector(node *VectorSelector, ts int64) Vector {
|
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)
|
ev.error(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1249,7 +1249,7 @@ func putPointSlice(p []Point) {
|
||||||
|
|
||||||
// matrixSelector evaluates a *MatrixSelector expression.
|
// matrixSelector evaluates a *MatrixSelector expression.
|
||||||
func (ev *evaluator) matrixSelector(node *MatrixSelector) Matrix {
|
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)
|
ev.error(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -606,9 +606,9 @@ func (ll *LazyLoader) parse(input string) error {
|
||||||
}
|
}
|
||||||
ll.loadCmd = cmd
|
ll.loadCmd = cmd
|
||||||
return nil
|
return nil
|
||||||
} else {
|
|
||||||
return raise(i, "invalid command %q", l)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return raise(i, "invalid command %q", l)
|
||||||
}
|
}
|
||||||
return errors.New("no \"load\" command found")
|
return errors.New("no \"load\" command found")
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue