diff --git a/.golangci.toml b/.golangci.toml index c028010c2..5486bc1ee 100644 --- a/.golangci.toml +++ b/.golangci.toml @@ -61,6 +61,7 @@ "exhaustivestruct", # Not relevant "makezero", # not relevant "forbidigo", # not relevant + "ifshort", # not relevant ] [issues] @@ -119,4 +120,4 @@ text = "printf-like formatting function 'SetErrorWithEvent' should be named 'SetErrorWithEventf'" [[issues.exclude-rules]] path = "pkg/log/deprecated.go" - linters = ["godot"] \ No newline at end of file + linters = ["godot"] diff --git a/build.Dockerfile b/build.Dockerfile index 29b4c1b24..2ed4a1217 100644 --- a/build.Dockerfile +++ b/build.Dockerfile @@ -19,7 +19,7 @@ RUN mkdir -p /usr/local/bin \ && chmod +x /usr/local/bin/go-bindata # Download golangci-lint binary to bin folder in $GOPATH -RUN curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | bash -s -- -b $GOPATH/bin v1.34.0 +RUN curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | bash -s -- -b $GOPATH/bin v1.36.0 # Download misspell binary to bin folder in $GOPATH RUN curl -sfL https://raw.githubusercontent.com/client9/misspell/master/install-misspell.sh | bash -s -- -b $GOPATH/bin v0.3.4 diff --git a/pkg/metrics/prometheus.go b/pkg/metrics/prometheus.go index b627b50b4..f936a0728 100644 --- a/pkg/metrics/prometheus.go +++ b/pkg/metrics/prometheus.go @@ -379,12 +379,12 @@ func (d *dynamicConfig) hasServerURL(serviceName, serverURL string) bool { return false } -func newCollector(metricName string, labels stdprometheus.Labels, c stdprometheus.Collector, delete func()) *collector { +func newCollector(metricName string, labels stdprometheus.Labels, c stdprometheus.Collector, deleteFn func()) *collector { return &collector{ id: buildMetricID(metricName, labels), labels: labels, collector: c, - delete: delete, + delete: deleteFn, } } diff --git a/pkg/middlewares/compress/compress_test.go b/pkg/middlewares/compress/compress_test.go index acee7346d..2c7fb97f4 100644 --- a/pkg/middlewares/compress/compress_test.go +++ b/pkg/middlewares/compress/compress_test.go @@ -284,9 +284,9 @@ func TestIntegrationShouldCompress(t *testing.T) { } } -func generateBytes(len int) []byte { +func generateBytes(length int) []byte { var value []byte - for i := 0; i < len; i++ { + for i := 0; i < length; i++ { value = append(value, 0x61+byte(i)) } return value diff --git a/pkg/middlewares/customerrors/custom_errors_test.go b/pkg/middlewares/customerrors/custom_errors_test.go index fca283bfa..025851871 100644 --- a/pkg/middlewares/customerrors/custom_errors_test.go +++ b/pkg/middlewares/customerrors/custom_errors_test.go @@ -29,6 +29,7 @@ func TestHandler(t *testing.T) { fmt.Fprintln(w, "My error page.") }), validate: func(t *testing.T, recorder *httptest.ResponseRecorder) { + t.Helper() assert.Equal(t, http.StatusOK, recorder.Code, "HTTP status") assert.Contains(t, recorder.Body.String(), http.StatusText(http.StatusOK)) }, @@ -41,6 +42,7 @@ func TestHandler(t *testing.T) { fmt.Fprintln(w, "My error page.") }), validate: func(t *testing.T, recorder *httptest.ResponseRecorder) { + t.Helper() assert.Equal(t, http.StatusPartialContent, recorder.Code, "HTTP status") assert.Contains(t, recorder.Body.String(), http.StatusText(http.StatusPartialContent)) }, @@ -53,6 +55,7 @@ func TestHandler(t *testing.T) { fmt.Fprintln(w, "whatever, should not be called") }), validate: func(t *testing.T, recorder *httptest.ResponseRecorder) { + t.Helper() assert.Equal(t, http.StatusNotModified, recorder.Code, "HTTP status") assert.Contains(t, recorder.Body.String(), "") }, @@ -65,6 +68,7 @@ func TestHandler(t *testing.T) { fmt.Fprintln(w, "My error page.") }), validate: func(t *testing.T, recorder *httptest.ResponseRecorder) { + t.Helper() assert.Equal(t, http.StatusInternalServerError, recorder.Code, "HTTP status") assert.Contains(t, recorder.Body.String(), "My error page.") assert.NotContains(t, recorder.Body.String(), "oops", "Should not return the oops page") @@ -78,6 +82,7 @@ func TestHandler(t *testing.T) { fmt.Fprintln(w, "My error page.") }), validate: func(t *testing.T, recorder *httptest.ResponseRecorder) { + t.Helper() assert.Equal(t, http.StatusBadGateway, recorder.Code, "HTTP status") assert.Contains(t, recorder.Body.String(), http.StatusText(http.StatusBadGateway)) assert.NotContains(t, recorder.Body.String(), "Test Server", "Should return the oops page since we have not configured the 502 code") @@ -95,6 +100,7 @@ func TestHandler(t *testing.T) { } }), validate: func(t *testing.T, recorder *httptest.ResponseRecorder) { + t.Helper() assert.Equal(t, http.StatusServiceUnavailable, recorder.Code, "HTTP status") assert.Contains(t, recorder.Body.String(), "My 503 page.") assert.NotContains(t, recorder.Body.String(), "oops", "Should not return the oops page") @@ -112,6 +118,7 @@ func TestHandler(t *testing.T) { } }), validate: func(t *testing.T, recorder *httptest.ResponseRecorder) { + t.Helper() assert.Equal(t, http.StatusServiceUnavailable, recorder.Code, "HTTP status") assert.Contains(t, recorder.Body.String(), "My 503 page.") assert.NotContains(t, recorder.Body.String(), "oops", "Should not return the oops page")