diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..61d129a --- /dev/null +++ b/Makefile @@ -0,0 +1,15 @@ +golangci-lint_version := v1.17.1 +gopath_prefix := $(HOME)/src +promremote_package := github.com/m3db/promremotebench# change this to m3dbx +promremote_package_path := $(gopath_prefix)/$(promremote_package)/src/cmd/promremotebench +src_relative_path := ./src/ + +install-linter: + echo "Installing golangci-lint..." + @PATH=$(GOPATH)/bin:$(PATH) which golangci-lint > /dev/null || "(curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $(go env GOPATH)/bin golangci-lint_version" + @PATH=$(GOPATH)/bin:$(PATH) which golangci-lint > /dev/null || (echo "golangci-lint install failed" && exit 1) + +linter: + make install-linter + @echo "--- linting promremotebench in $(promremote_package_path)" + cd $(src_relative_path) && golangci-lint run diff --git a/src/cmd/promremotebench/checker.go b/src/cmd/promremotebench/checker.go index aac01d2..3e3d8b3 100644 --- a/src/cmd/promremotebench/checker.go +++ b/src/cmd/promremotebench/checker.go @@ -95,7 +95,7 @@ func (c *checker) GetHostNames() []string { c.RLock() results := make([]string, len(c.values)) i := 0 - for host, _ := range c.values { + for host := range c.values { results[i] = host i++ } diff --git a/src/cmd/promremotebench/query.go b/src/cmd/promremotebench/query.go index 5effe7a..1c3f12e 100644 --- a/src/cmd/promremotebench/query.go +++ b/src/cmd/promremotebench/query.go @@ -278,6 +278,7 @@ func (q *queryExecutor) executeQuery(query *strings.Builder, retResult bool, que } defer func() { + //nolint:errcheck io.Copy(ioutil.Discard, resp.Body) resp.Body.Close() }() @@ -352,7 +353,6 @@ func (q *queryExecutor) validateQuery(dps Datapoints, data []byte) bool { for _, value := range matrix[0].Values { for i < len(dps) { if float64(value.Value) == dps[i].Value { - i++ matches++ break } diff --git a/src/cmd/promremotebench/write.go b/src/cmd/promremotebench/write.go index 29d068b..c67958e 100644 --- a/src/cmd/promremotebench/write.go +++ b/src/cmd/promremotebench/write.go @@ -131,7 +131,6 @@ var userAgent = fmt.Sprintf("Prometheus/%s", version.Version) // Client allows reading and writing from/to a remote HTTP endpoint. type Client struct { - index int // Used to differentiate clients in metrics. url string client *http.Client timeout time.Duration @@ -180,6 +179,7 @@ func (c *Client) Store(ctx context.Context, req []byte) error { return recoverableError{err} } defer func() { + //nolint:errcheck io.Copy(ioutil.Discard, httpResp.Body) httpResp.Body.Close() }() diff --git a/src/cmd/promremotebench/write_test.go b/src/cmd/promremotebench/write_test.go index b24fa83..82ae5ba 100644 --- a/src/cmd/promremotebench/write_test.go +++ b/src/cmd/promremotebench/write_test.go @@ -44,10 +44,8 @@ import ( func TestRemoteWrite(t *testing.T) { logger := instrument.NewOptions().Logger() tests := []struct { - name string - numHosts int - expectedBatches int - expectedSeries int + name string + numHosts int }{ { name: "one host",