From bf10a467843c1d45d7eade5ae449c15b329141af Mon Sep 17 00:00:00 2001 From: Ludovic Fernandez Date: Thu, 9 May 2024 21:31:20 +0200 Subject: [PATCH] chore: update linter (#2183) --- .github/workflows/pr.yml | 2 +- .golangci.yml | 22 ++++++++++------------ internal/dnsdocs/generator.go | 12 ++++++------ providers/dns/constellix/constellix.go | 4 ++-- 4 files changed, 19 insertions(+), 21 deletions(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index e4501d23..5f54209a 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -13,7 +13,7 @@ jobs: runs-on: ubuntu-latest env: GO_VERSION: stable - GOLANGCI_LINT_VERSION: v1.57.1 + GOLANGCI_LINT_VERSION: v1.58.1 HUGO_VERSION: 0.117.0 CGO_ENABLED: 0 LEGO_E2E_TESTS: CI diff --git a/.golangci.yml b/.golangci.yml index 2e74d103..16750641 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -99,16 +99,7 @@ linters-settings: linters: enable-all: true disable: - - deadcode # deprecated - - exhaustivestruct # deprecated - - golint # deprecated - - ifshort # deprecated - - interfacer # deprecated - - maligned # deprecated - - nosnakecase # deprecated - - scopelint # deprecated - - structcheck # deprecated - - varcheck # deprecated + - gomnd # deprecated - cyclop # duplicate of gocyclo - sqlclosecheck # not relevant (SQL) - rowserrcheck # not relevant (SQL) @@ -118,13 +109,13 @@ linters: - dupl # not relevant - prealloc # too many false-positive - bodyclose # too many false-positive - - gomnd + - mnd - testpackage # not relevant - tparallel # not relevant - paralleltest # not relevant - nestif # too many false-positive - wrapcheck - - goerr113 # not relevant + - err113 # not relevant - nlreturn # not relevant - wsl # not relevant - exhaustive # not relevant @@ -145,6 +136,7 @@ linters: - musttag # false-positive https://github.com/junk1tm/musttag/issues/17 - gosmopolitan # not relevant - exportloopref # Useless with go1.22 + - canonicalheader # Can create side effects in the context of API clients issues: exclude-use-default: false @@ -234,3 +226,9 @@ issues: text: 'cyclomatic complexity \d+ of func `(renewForDomains|renewForCSR)` is high' - path: providers/dns/cpanel/cpanel.go text: 'cyclomatic complexity 13 of func `\(\*DNSProvider\)\.CleanUp` is high' + +output: + sort-results: true + sort-order: + - linter + - file diff --git a/internal/dnsdocs/generator.go b/internal/dnsdocs/generator.go index 812b87ee..c19c370e 100644 --- a/internal/dnsdocs/generator.go +++ b/internal/dnsdocs/generator.go @@ -155,7 +155,7 @@ func generateCLIHelp(models *Providers) error { } func generateReadMe(models *Providers) error { - max, lines := extractTableData(models) + maximum, lines := extractTableData(models) file, err := os.Open(readmePath) if err != nil { @@ -174,7 +174,7 @@ func generateReadMe(models *Providers) error { if text == startLine { _, _ = fmt.Fprintln(buffer, text) - err = writeDNSTable(buffer, lines, max) + err = writeDNSTable(buffer, lines, maximum) if err != nil { return err } @@ -208,14 +208,14 @@ func extractTableData(models *Providers) (int, [][]string) { items := []string{fmt.Sprintf(readmePattern, "Manual", "manual")} - var max int + var maximum int for _, pvd := range models.Providers { item := fmt.Sprintf(readmePattern, strings.ReplaceAll(pvd.Name, "|", "/"), pvd.Code) items = append(items, item) - if max < len(item) { - max = len(item) + if maximum < len(item) { + maximum = len(item) } } @@ -253,7 +253,7 @@ func extractTableData(models *Providers) (int, [][]string) { lines = append(lines, line) } - return max, lines + return maximum, lines } func writeDNSTable(w io.Writer, lines [][]string, size int) error { diff --git a/providers/dns/constellix/constellix.go b/providers/dns/constellix/constellix.go index 10b75e9a..a7e81371 100644 --- a/providers/dns/constellix/constellix.go +++ b/providers/dns/constellix/constellix.go @@ -280,7 +280,7 @@ func containsValue(record *internal.Record, value string) bool { }) } -func backoff(min, max time.Duration, attemptNum int, resp *http.Response) time.Duration { +func backoff(minimum, maximum time.Duration, attemptNum int, resp *http.Response) time.Duration { if resp != nil { // https://api.dns.constellix.com/v4/docs#section/Using-the-API/Rate-Limiting if resp.StatusCode == http.StatusTooManyRequests { @@ -292,5 +292,5 @@ func backoff(min, max time.Duration, attemptNum int, resp *http.Response) time.D } } - return retryablehttp.DefaultBackoff(min, max, attemptNum, resp) + return retryablehttp.DefaultBackoff(minimum, maximum, attemptNum, resp) }