From 115fb89b1e83d0980ed7f41324d6441f995e6d91 Mon Sep 17 00:00:00 2001 From: Yury Tsarev Date: Thu, 13 Mar 2025 21:59:37 +0100 Subject: [PATCH] Update golangci configuration to work with latest linter versions * Follow golangci-lint config verify errors and fix according to the latest https://golangci-lint.run/usage/configuration/ and https://golangci-lint.run/usage/linters * It should proactively fix the associated pipeline failures Signed-off-by: Yury Tsarev --- .golangci.yml | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 1cbfbd0..f5a0ef2 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,12 +1,10 @@ run: timeout: 10m - skip-files: - - "zz_generated\\..+\\.go$" - output: # colored-line-number|line-number|json|tab|checkstyle|code-climate, default is "colored-line-number" - format: colored-line-number + formats: + - format: colored-line-number linters-settings: errcheck: @@ -18,14 +16,15 @@ linters-settings: # default is false: such cases aren't reported by default. check-blank: false - # [deprecated] comma-separated list of pairs of the form pkg:regex - # the regex is used to ignore names within pkg. (default "fmt:.*"). - # see https://github.com/kisielk/errcheck#the-deprecated-method for details - ignore: fmt:.*,io/ioutil:^Read.* + # List of functions to exclude from checking, where each entry is a single function to exclude. + # See https://github.com/kisielk/errcheck#excluding-functions for details. + exclude-functions: + - io/ioutil.ReadFile govet: # report about shadowed variables - check-shadowing: false + disable: + - shadow gofmt: # simplify code: gofmt with `-s` option, true by default @@ -45,10 +44,6 @@ linters-settings: # minimal code complexity to report, 30 by default (but we recommend 10-20) min-complexity: 10 - maligned: - # print struct with more effective memory layout or not, false by default - suggest-new: true - dupl: # tokens count to trigger issue, 150 by default threshold: 100 @@ -116,7 +111,7 @@ linters: - misspell - nakedret - nolintlint - + disable: # These linters are all deprecated as of golangci-lint v1.49.0. We disable # them explicitly to avoid the linter logging deprecation warnings. @@ -135,6 +130,9 @@ linters: issues: # Excluding configuration per-path and per-linter exclude-rules: + - path: "zz_generated\\..+\\.go$" + linters: ["all"] + # Exclude some linters from running on tests files. - path: _test(ing)?\.go linters: @@ -181,7 +179,7 @@ issues: linters: - gosec - gas - + # Some k8s dependencies do not have JSON tags on all fields in structs. - path: k8s.io/ linters: @@ -202,7 +200,7 @@ issues: new: false # Maximum issues count per one linter. Set to 0 to disable. Default is 50. - max-per-linter: 0 + max-issues-per-linter: 0 # Maximum count of issues with the same text. Set to 0 to disable. Default is 3. max-same-issues: 0