diff --git a/stress/basic.go b/stress/basic.go index 36ad9c2ffc..aa9915c6b0 100644 --- a/stress/basic.go +++ b/stress/basic.go @@ -389,7 +389,7 @@ type BasicQuery struct { // QueryGenerate returns a Query channel func (q *BasicQuery) QueryGenerate(now func() time.Time) (<-chan Query, error) { - c := make(chan Query, 0) + c := make(chan Query) go func(chan Query) { defer close(c) @@ -406,7 +406,6 @@ func (q *BasicQuery) QueryGenerate(now func() time.Time) (<-chan Query, error) { // SetTime sets the internal state of time func (q *BasicQuery) SetTime(t time.Time) { q.time = t - return } // BasicQueryClient implements the QueryClient interface @@ -513,11 +512,7 @@ func resetDB(c client.Client, database string) error { _, err = c.Query(client.Query{ Command: fmt.Sprintf("CREATE DATABASE %s", database), }) - if err != nil { - return err - } - - return nil + return err } // BasicProvisioner implements the Provisioner @@ -562,7 +557,7 @@ func NewBroadcastChannel() *BroadcastChannel { } func (b *BroadcastChannel) Register(fn responseHandler) { - ch := make(chan response, 0) + ch := make(chan response) b.chs = append(b.chs, ch) diff --git a/stress/run.go b/stress/run.go index d1cf872f56..378b3fe4a5 100644 --- a/stress/run.go +++ b/stress/run.go @@ -269,7 +269,7 @@ func (s *StressTest) Start(wHandle responseHandler, rHandle responseHandler) { wg.Add(1) // Starts Writing go func() { - r := make(chan response, 0) + r := make(chan response) wt := NewTimer() go func() { diff --git a/stress/stress_test.go b/stress/stress_test.go index 94db4654b9..db22be8ba3 100644 --- a/stress/stress_test.go +++ b/stress/stress_test.go @@ -322,8 +322,8 @@ func TestBasicClient_send(t *testing.T) { } func TestBasicClient_Batch(t *testing.T) { - c := make(chan Point, 0) - r := make(chan response, 0) + c := make(chan Point) + r := make(chan response) ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { content, _ := ioutil.ReadAll(r.Body) @@ -348,11 +348,6 @@ func TestBasicClient_Batch(t *testing.T) { }(c) - go func(r chan response) { - for _ = range r { - } - }(r) - err := basicIC.Batch(c, r) close(r) if err != nil { @@ -395,8 +390,6 @@ func TestBasicQueryClient_Query(t *testing.T) { var data client.Response w.WriteHeader(http.StatusOK) _ = json.NewEncoder(w).Encode(data) - - return })) defer ts.Close() @@ -438,7 +431,7 @@ func Test_NewConfigWithFile(t *testing.T) { if p.Basic.Database != "stress" { t.Errorf("Expected `stress` got %s", p.Basic.Database) } - if p.Basic.ResetDatabase != true { + if !p.Basic.ResetDatabase { t.Errorf("Expected true got %v", p.Basic.ResetDatabase) } @@ -480,8 +473,8 @@ func Test_NewConfigWithFile(t *testing.T) { if wc.Concurrency != 10 { t.Errorf("Expected 10 got %v", wc.Concurrency) } - if wc.SSL != false { - t.Errorf("Expected 10 got %v", wc.SSL) + if wc.SSL { + t.Errorf("Expected true got %v", wc.SSL) } if wc.Format != "line_http" { t.Errorf("Expected `line_http` got %s", wc.Format) @@ -525,7 +518,7 @@ func Test_NewConfigWithoutFile(t *testing.T) { if p.Basic.Database != "stress" { t.Errorf("Expected `stress` got %s", p.Basic.Database) } - if p.Basic.ResetDatabase != true { + if !p.Basic.ResetDatabase { t.Errorf("Expected true got %v", p.Basic.ResetDatabase) } @@ -567,8 +560,8 @@ func Test_NewConfigWithoutFile(t *testing.T) { if wc.Concurrency != 10 { t.Errorf("Expected 10 got %v", wc.Concurrency) } - if wc.SSL != false { - t.Errorf("Expected 10 got %v", wc.SSL) + if wc.SSL { + t.Errorf("Expected true got %v", wc.SSL) } if wc.Format != "line_http" { t.Errorf("Expected `line_http` got %s", wc.Format) diff --git a/stress/v2/statement/function_test.go b/stress/v2/statement/function_test.go index c9b134f661..ae793cde2d 100644 --- a/stress/v2/statement/function_test.go +++ b/stress/v2/statement/function_test.go @@ -87,10 +87,6 @@ func TestStringersEval(t *testing.T) { if parseFloat(values[4].(string)) > floatRandFunction.Argument { t.Errorf("Expected value below: %v\nGot value: %v\n", floatRandFunction.Argument, values[4]) } - // Check the spoofTime func - if values[5] != 8 { - - } } func spoofTime() int64 { diff --git a/stress/v2/stress_client/stressTest.go b/stress/v2/stress_client/stressTest.go index 1deed7e88d..646d3bdc3b 100644 --- a/stress/v2/stress_client/stressTest.go +++ b/stress/v2/stress_client/stressTest.go @@ -11,9 +11,9 @@ import ( // NewStressTest creates the backend for the stress test func NewStressTest() *StressTest { - packageCh := make(chan Package, 0) - directiveCh := make(chan Directive, 0) - responseCh := make(chan Response, 0) + packageCh := make(chan Package) + directiveCh := make(chan Directive) + responseCh := make(chan Response) clnt, _ := influx.NewHTTPClient(influx.HTTPConfig{ Addr: fmt.Sprintf("http://%v/", "localhost:8086"), @@ -46,8 +46,8 @@ func NewStressTest() *StressTest { // NewTestStressTest returns a StressTest to be used for testing Statements func NewTestStressTest() (*StressTest, chan Package, chan Directive) { - packageCh := make(chan Package, 0) - directiveCh := make(chan Directive, 0) + packageCh := make(chan Package) + directiveCh := make(chan Directive) s := &StressTest{ TestDB: "_stressTest", diff --git a/stress/v2/stress_client/stress_client_query.go b/stress/v2/stress_client/stress_client_query.go index 3cb64c571d..f2a48658a4 100644 --- a/stress/v2/stress_client/stress_client_query.go +++ b/stress/v2/stress_client/stress_client_query.go @@ -67,8 +67,3 @@ func (sc *stressClient) makeGet(addr, statementID string, tr *Tracer) { // Send the response sc.responseChan <- NewResponse(sc.queryPoint(statementID, body, resp.StatusCode, elapsed, tr.Tags), tr) } - -func success(r *http.Response) bool { - // ADD success for tcp, udp, etc - return r != nil && (r.StatusCode == 204 || r.StatusCode == 200) -} diff --git a/stress/v2/stressql/statement/parser.go b/stress/v2/stressql/statement/parser.go index 57e802bdd5..7eb71e776c 100644 --- a/stress/v2/stressql/statement/parser.go +++ b/stress/v2/stressql/statement/parser.go @@ -57,6 +57,11 @@ const ( keywordEnd ) +// These assignments prevent static analysis tools highlighting lack of use of +// boundary constants. +var _, _ = literalBeg, literalEnd +var _, _ = keywordBeg, keywordEnd + var eof = rune(1) func isWhitespace(ch rune) bool { return ch == ' ' || ch == '\t' || ch == '\n' }