Skip to content

Commit

Permalink
more linting fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
buixor committed May 20, 2020
1 parent fe68914 commit e6cad40
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 17 deletions.
7 changes: 0 additions & 7 deletions pkg/leakybucket/buckets_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,6 @@ type TestFile struct {
Results []types.Event `yaml:"results,omitempty"`
}

func testBucketStates() {
//same as a scenario, but load a bucket state first ?

}

func TestBucket(t *testing.T) {

var envSetting = os.Getenv("TEST_ONLY")
Expand Down Expand Up @@ -261,7 +256,5 @@ POLL_AGAIN:
log.Warningf("entry valid at end of loop")
}
}

t.Errorf("failed test")
return false
}
6 changes: 3 additions & 3 deletions pkg/parser/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ func (n *Node) compile(pctx *UnixParserCtx) error {
/* load grok statics */
if len(n.Grok.Statics) > 0 {
//compile expr statics if present
for idx, _ := range n.Grok.Statics {
for idx := range n.Grok.Statics {
if n.Grok.Statics[idx].ExpValue != "" {
n.Grok.Statics[idx].RunTimeValue, err = expr.Compile(n.Grok.Statics[idx].ExpValue,
expr.Env(exprhelpers.GetExprEnv(map[string]interface{}{"evt": &types.Event{}})))
Expand All @@ -412,7 +412,7 @@ func (n *Node) compile(pctx *UnixParserCtx) error {
}
/* compile leafs if present */
if len(n.SuccessNodes) > 0 {
for idx, _ := range n.SuccessNodes {
for idx := range n.SuccessNodes {
/*propagate debug/stats to child nodes*/
if !n.SuccessNodes[idx].Debug && n.Debug {
n.SuccessNodes[idx].Debug = true
Expand All @@ -432,7 +432,7 @@ func (n *Node) compile(pctx *UnixParserCtx) error {
valid = true
}
/* load statics if present */
for idx, _ := range n.Statics {
for idx := range n.Statics {
if n.Statics[idx].ExpValue != "" {
n.Statics[idx].RunTimeValue, err = expr.Compile(n.Statics[idx].ExpValue, expr.Env(exprhelpers.GetExprEnv(map[string]interface{}{"evt": &types.Event{}})))
if err != nil {
Expand Down
6 changes: 3 additions & 3 deletions pkg/parser/runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,11 @@ func ProcessStatics(statics []types.ExtraField, p *types.Event, clog *logrus.Ent
clog.Warningf("failed to run RunTimeValue : %v", err)
continue
}
switch output.(type) {
switch out := output.(type) {
case string:
value = output.(string)
value = out
case int:
value = strconv.Itoa(output.(int))
value = strconv.Itoa(out)
default:
clog.Fatalf("unexpected return type for RunTimeValue : %T", output)
return errors.New("unexpected return type for RunTimeValue")
Expand Down
6 changes: 3 additions & 3 deletions pkg/sqlite/stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ func (c *Context) GetBansAt(at time.Time) ([]map[string]string, error) {
bancom["source"] = ba.MeasureSource
bancom["events_count"] = "0"
bancom["action"] = ba.MeasureType
bancom["until"] = fmt.Sprintf("%s", ba.Until.Sub(time.Now()).Round(time.Second))
bancom["until"] = time.Until(ba.Until).Round(time.Second).String()
bancom["reason"] = ba.Reason
rets = append(rets, bancom)
continue
Expand All @@ -134,7 +134,7 @@ func (c *Context) GetBansAt(at time.Time) ([]map[string]string, error) {
bancom["scenario"] = "?"
bancom["events_count"] = "0"
bancom["action"] = ba.MeasureType
bancom["until"] = fmt.Sprintf("%s", ba.Until.Sub(time.Now()).Round(time.Second))
bancom["until"] = time.Until(ba.Until).Round(time.Second).String()
bancom["reason"] = ba.Reason
rets = append(rets, bancom)
continue
Expand All @@ -155,7 +155,7 @@ func (c *Context) GetBansAt(at time.Time) ([]map[string]string, error) {
bancom["events_count"] = fmt.Sprintf("%d", evtCount)
bancom["action"] = ba.MeasureType
bancom["source"] = ba.MeasureSource
bancom["until"] = fmt.Sprintf("%s", ba.Until.Sub(time.Now()).Round(time.Second))
bancom["until"] = time.Until(ba.Until).Round(time.Second).String()
bancom["reason"] = so.Scenario
rets = append(rets, bancom)
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/time/rate/rate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ type wait struct {
func runWait(t *testing.T, lim *Limiter, w wait) {
start := time.Now()
err := lim.WaitN(w.ctx, w.n)
delay := time.Now().Sub(start)
delay := time.Since(start)
if (w.nilErr && err != nil) || (!w.nilErr && err == nil) || w.delay != dFromDuration(delay) {
errString := "<nil>"
if !w.nilErr {
Expand Down

0 comments on commit e6cad40

Please sign in to comment.