minor improvements from static code analysis
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
Tessa Nordgren 2022-02-18 12:09:52 -08:00
parent 714462c36f
commit 5d5af6e926
5 changed files with 5 additions and 13 deletions

1
go.sum
View File

@ -1,3 +1,4 @@
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/eapache/queue.v1 v1.1.0 h1:EldqoJEGtXYiVCMRo2C9mePO2UUGnYn2+qLmlQSqPdc= gopkg.in/eapache/queue.v1 v1.1.0 h1:EldqoJEGtXYiVCMRo2C9mePO2UUGnYn2+qLmlQSqPdc=
gopkg.in/eapache/queue.v1 v1.1.0/go.mod h1:wNtmx1/O7kZSR9zNT1TTOJ7GLpm3Vn7srzlfylFbQwU= gopkg.in/eapache/queue.v1 v1.1.0/go.mod h1:wNtmx1/O7kZSR9zNT1TTOJ7GLpm3Vn7srzlfylFbQwU=

View File

@ -4,16 +4,13 @@ import (
"runtime" "runtime"
"sync" "sync"
"testing" "testing"
"time"
) )
var testQ = NewQueue() var testQ = NewQueue()
func testAdd(n int) { func testAdd(n int) {
for i := 0; i < n; i++ { for i := 0; i < n; i++ {
testQ.Add(func() { testQ.Add(func() {})
time.Sleep(1)
})
} }
} }

View File

@ -33,10 +33,7 @@ func SimpleScheduler(tq *TaskQueue) bool {
queued++ queued++
} }
} }
if queued > 0 { return (queued > 0)
return true
}
return false
} }
// TimeSliceScheduler attempts to give tasks a fair share of the Stats() // TimeSliceScheduler attempts to give tasks a fair share of the Stats()

View File

@ -74,7 +74,7 @@ func (s *Stat) Start() (start time.Time) {
// This will fluctuate between 90-100% of the window size set when the state // This will fluctuate between 90-100% of the window size set when the state
// was created, as internal buckets roll over. // was created, as internal buckets roll over.
func (s *Stat) Duration() time.Duration { func (s *Stat) Duration() time.Duration {
return time.Now().Sub(s.Start()) return time.Since(s.Start())
} }
// Rate returns the flow rate of this counter, which is the current rolling // Rate returns the flow rate of this counter, which is the current rolling

View File

@ -11,10 +11,7 @@ func (list UIntSlice) Len() int {
// Less helps fulfill sort.Interface. // Less helps fulfill sort.Interface.
func (list UIntSlice) Less(i, j int) bool { func (list UIntSlice) Less(i, j int) bool {
if list[i] <= list[j] { return list[i] <= list[j]
return true
}
return false
} }
// Swap helps fulfill sort.Interface // Swap helps fulfill sort.Interface