From acf8e65f787c1e1c598241ea4bc29da62c6d2041 Mon Sep 17 00:00:00 2001 From: Dave Protasowski Date: Thu, 9 Jan 2025 22:27:05 -0500 Subject: [PATCH] fix whitespace --- .golangci.yaml | 212 ++++++++++++++++-- pkg/apis/config/store_test.go | 1 - .../v1alpha1/ingress_defaults_test.go | 1 - test/conformance/ingress/class.go | 1 - test/conformance/ingress/headers.go | 2 - test/conformance/ingress/visibility.go | 1 - test/test_images/httpproxy/httpproxy.go | 1 - 7 files changed, 198 insertions(+), 21 deletions(-) diff --git a/.golangci.yaml b/.golangci.yaml index 1e75e309e..5fbed11c9 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -1,29 +1,213 @@ run: - timeout: 5m - + timeout: 10m + allow-parallel-runners: true + exclude-dirs: + - pkg/client build-tags: - - e2e + - e2e + +output: + sort-results: true + sort-order: + - linter + - file + show-stats: true + + +issues: + uniq-by-line: true + max-issues-per-linter: 0 + max-same-issues: 0 + exclude-rules: + - path: test # Excludes /test, *_test.go etc. + linters: + - gosec + - unparam + - noctx + - protogetter + - linters: ["gocritic"] + # Fixes are non-trivial do in a follow up + text: "ifElseChain" - skip-dirs: - - pkg/client +linters-settings: + intrange: + severity: warning + gomodguard: + blocked: + modules: + - github.com/ghodss/yaml: + recommendations: + - sigs.k8s.io/yaml + - go.uber.org/atomic: + recommendations: + - sync/atomic + - io/ioutil: + recommendations: + - os + - io + - github.com/hashicorp/go-multierror: + reason: "use errors.Join" + recommendations: + - errors + - go.uber.org/multierr: + reason: "use errors.Join" + recommendations: + - errors + revive: + rules: + # use unparam linter instead - defaults are better + - name: unused-parameter + disabled: true linters: + disable: + - errcheck enable: + # Check for pass []any as any in variadic func(...any). + - asasalint + + # Only use ASCII chars in indentifiers - asciicheck + + # Dangerous unicode characters + - bidichk + + # Checks whether HTTP response body is closed successfully. + - bodyclose + + # Canonicalheader checks whether net/http.Header uses canonical header. + - canonicalheader + + # TODO - do a follow up PR + # # Containedctx is a linter that detects struct contained context.Context + # # field. + # - containedctx + + # TODO - do a follow up PR + # # Check whether the function uses a non-inherited context. + # - contextcheck + + # Copyloopvar is a linter detects places where loop variables are copied. + - copyloopvar + + # Check declaration order of types, consts, vars and funcs. + - decorder + + # Check for two durations multiplied together. + - durationcheck + + # Checks that sentinel errors are prefixed with the Err- and error types + # are suffixed with the -Error. + - errname + + # Errorlint is a linter for that can be used to find code that will cause + # problems with the error wrapping scheme introduced in Go 1.13. - errorlint + + # Detects nested contexts in loops. + - fatcontext + + # Checks that go compiler directive comments (//go:) are valid. + - gocheckcompilerdirectives + + # Provides diagnostics that check for bugs, performance and style issues. + # Extensible without recompilation through dynamic rules. + # Dynamic rules are written declaratively with AST patterns, filters, + # report message and optional suggestion. + - gocritic + + # Gofmt checks whether code was gofmt-ed. By default this tool runs + # with -s option to check for code simplification. + - gofmt + + # Gofumpt checks whether code was gofumpt-ed. + - gofumpt + + # Check import statements are formatted according to the 'goimport' + # command. Reformat imports in autofix mode. + - goimports + + # See config below + - gomodguard + + # Inspects source code for security problems. - gosec + + # Linter that specializes in simplifying code. + - gosimple + - govet + + # Intrange is a linter to find places where for loops could make use of + # an integer range. + - intrange + + # Checks key value pairs for common logger libraries (kitlog,klog,logr,zap). + - loggercheck + + # Finds slice declarations with non-zero initial length. + - makezero + + # Reports wrong mirror patterns of bytes/strings usage + - mirror + + # Finds commonly misspelled English words. + - misspell + + # Finds the code that returns nil even if it checks that the error is not nil. + - nilerr + + # Finds sending HTTP request without context.Context. + - noctx + + # Reports ill-formed or insufficient nolint directives. + - nolintlint + + # Checks for misuse of Sprintf to construct a host with port in a URL. + - nosprintfhostport + + # Checks that fmt.Sprintf can be replaced with a faster alternative. + - perfsprint + + # Finds slice declarations that could potentially be pre-allocated. - prealloc + + # Reports direct reads from proto message fields when getters should be used. + - protogetter + + # Checks that package variables are not reassigned. + - reassign + + # Fast, configurable, extensible, flexible, and beautiful linter for + # Go. Drop-in replacement of golint. - revive + + # Checks for mistakes with OpenTelemetry/Census spans. + - spancheck + + # Stylecheck is a replacement for golint. - stylecheck - - tparallel + + # Tenv is analyzer that detects using os.Setenv instead of t.Setenv + # since Go1.17. + - tenv + + # Linter checks if examples are testable (have an expected output). + - testableexamples + + # Remove unnecessary type conversions. - unconvert + + # Reports unused function parameters and results in your code. - unparam - disable: - - errcheck -issues: - exclude-rules: - - path: test # Excludes /test, *_test.go etc. - linters: - - gosec - - unparam + # A linter that detect the possibility to use variables/constants from the + # Go standard library. + - usestdlibvars + + # Finds wasted assignment statements. + - wastedassign + + # Whitespace is a linter that checks for unnecessary newlines at the start + # and end of functions, if, for, etc. + - whitespace + diff --git a/pkg/apis/config/store_test.go b/pkg/apis/config/store_test.go index ebe774d25..4f08de14a 100644 --- a/pkg/apis/config/store_test.go +++ b/pkg/apis/config/store_test.go @@ -47,7 +47,6 @@ func TestStoreLoadWithContext(t *testing.T) { t.Error("Unexpected defaults config (-want, +got):", diff) } }) - } func TestStoreLoadWithContextOrDefaults(t *testing.T) { diff --git a/pkg/apis/networking/v1alpha1/ingress_defaults_test.go b/pkg/apis/networking/v1alpha1/ingress_defaults_test.go index 0f8e4e8ad..4227b8145 100644 --- a/pkg/apis/networking/v1alpha1/ingress_defaults_test.go +++ b/pkg/apis/networking/v1alpha1/ingress_defaults_test.go @@ -147,5 +147,4 @@ func TestIngressDefaulting(t *testing.T) { } }) } - } diff --git a/test/conformance/ingress/class.go b/test/conformance/ingress/class.go index 2a2142500..d233c2308 100644 --- a/test/conformance/ingress/class.go +++ b/test/conformance/ingress/class.go @@ -67,7 +67,6 @@ func TestIngressClass(t *testing.T) { verifyIngressWithAnnotations(ctx, t, clients, test.annotations, ingressBackend) }) } - } func verifyIngressWithAnnotations(ctx context.Context, t *testing.T, clients *test.Clients, diff --git a/test/conformance/ingress/headers.go b/test/conformance/ingress/headers.go index 83c2c6522..4488b4463 100644 --- a/test/conformance/ingress/headers.go +++ b/test/conformance/ingress/headers.go @@ -106,7 +106,6 @@ func TestProbeHeaders(t *testing.T) { } }) } - } // TestTagHeaders verifies that an Ingress properly dispatches to backends based on the tag header @@ -210,7 +209,6 @@ func TestTagHeaders(t *testing.T) { } }) } - } // TestPreSplitSetHeaders verifies that an Ingress that specified AppendHeaders pre-split has the appropriate header(s) set. diff --git a/test/conformance/ingress/visibility.go b/test/conformance/ingress/visibility.go index e68712f70..b673a22ee 100644 --- a/test/conformance/ingress/visibility.go +++ b/test/conformance/ingress/visibility.go @@ -79,7 +79,6 @@ func TestVisibility(t *testing.T) { } func testProxyToHelloworld(ctx context.Context, t *testing.T, ingress *v1alpha1.Ingress, clients *test.Clients, privateHostName string) { - loadbalancerAddress := ingress.Status.PrivateLoadBalancer.Ingress[0].DomainInternal proxyName, proxyPort, _ := CreateProxyService(ctx, t, clients, privateHostName, loadbalancerAddress) diff --git a/test/test_images/httpproxy/httpproxy.go b/test/test_images/httpproxy/httpproxy.go index 563fa0eb6..385dbd3a4 100644 --- a/test/test_images/httpproxy/httpproxy.go +++ b/test/test_images/httpproxy/httpproxy.go @@ -103,7 +103,6 @@ func main() { log.Print("Listening on address: ", address) test.ListenAndServeGracefully(address, handler) } - } // newDNSCachingTransport caches DNS lookups locally to avoid issues like