diff --git a/.golangci.toml b/.golangci.toml index 73475dcb2..1b069b1c2 100644 --- a/.golangci.toml +++ b/.golangci.toml @@ -1,6 +1,9 @@ [run] deadline = "10m" skip-files = [] + skip-dirs = [ + "pkg/provider/kubernetes/crd/generated/", + ] [linters-settings] @@ -40,9 +43,11 @@ "scopelint", "gochecknoinits", "gochecknoglobals", -# "godox", # manage TODO FIXME ## wait for https://github.com/golangci/golangci-lint/issues/337 + "godox", + "gocognit", "bodyclose", # Too many false-positive and panics. -# "stylecheck", # skip because report issues related to some generated files. ## wait for https://github.com/golangci/golangci-lint/issues/337 + "wsl", # Too strict + "stylecheck", # skip because report issues related to some generated files. ] [issues] diff --git a/build.Dockerfile b/build.Dockerfile index 542617644..a37091948 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.18.0 +RUN curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | bash -s -- -b $GOPATH/bin v1.20.0 # Download golangci-lint and misspell binary to bin folder in $GOPATH RUN GO111MODULE=off go get github.com/client9/misspell/cmd/misspell diff --git a/pkg/job/job_test.go b/pkg/job/job_test.go index 5e3c488e6..60e4086cb 100644 --- a/pkg/job/job_test.go +++ b/pkg/job/job_test.go @@ -33,13 +33,14 @@ func TestJobBackOff(t *testing.T) { // Assert that the next backoff falls in the expected range. var minInterval = expected - time.Duration(testRandomizationFactor*float64(expected)) var maxInterval = expected + time.Duration(testRandomizationFactor*float64(expected)) + if i < 3 || i == 8 { time.Sleep(2 * time.Second) } + var actualInterval = exp.NextBackOff() if !(minInterval <= actualInterval && actualInterval <= maxInterval) { t.Error("error") } - // assertEquals(t, expected, exp.currentInterval) } } diff --git a/pkg/safe/routine_test.go b/pkg/safe/routine_test.go index d44d03f58..f9e8a6ab9 100644 --- a/pkg/safe/routine_test.go +++ b/pkg/safe/routine_test.go @@ -12,6 +12,7 @@ import ( func TestNewPoolContext(t *testing.T) { type testKeyType string + testKey := testKeyType("test") ctx := context.WithValue(context.Background(), testKey, "test") diff --git a/pkg/tracing/tracing.go b/pkg/tracing/tracing.go index 82d5f2226..2d19aa7da 100644 --- a/pkg/tracing/tracing.go +++ b/pkg/tracing/tracing.go @@ -91,10 +91,7 @@ func (t *Tracing) Extract(format interface{}, carrier interface{}) (opentracing. // IsEnabled determines if tracing was successfully activated. func (t *Tracing) IsEnabled() bool { - if t == nil || t.tracer == nil { - return false - } - return true + return t != nil && t.tracer != nil } // Close tracer @@ -169,9 +166,7 @@ func StartSpan(r *http.Request, operationName string, spanKind ext.SpanKindEnum, } r = r.WithContext(ctx) - return span, r, func() { - span.Finish() - } + return span, r, func() { span.Finish() } } // SetError flags the span associated with this request as in error.