From 0cb90694434045de4818e7187f6bd05bbf77810f Mon Sep 17 00:00:00 2001 From: Matthieu MOREL Date: Wed, 25 Feb 2026 07:35:57 +0100 Subject: [PATCH] chore: enable modernize linter Signed-off-by: Matthieu MOREL --- .github/env | 2 +- .golangci.yml | 33 ++++++++++++++++++++---------- pkg/downloader/chart_downloader.go | 4 ++-- 3 files changed, 25 insertions(+), 14 deletions(-) diff --git a/.github/env b/.github/env index 9d79b174f..a22fa80ca 100644 --- a/.github/env +++ b/.github/env @@ -1,2 +1,2 @@ GOLANG_VERSION=1.25 -GOLANGCI_LINT_VERSION=v2.5.0 +GOLANGCI_LINT_VERSION=v2.10.1 diff --git a/.golangci.yml b/.golangci.yml index 7eca135e5..89cc4d11d 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -17,13 +17,16 @@ formatters: linters: default: none + # Keep sorted alphabetically enable: - depguard - dupl + - exhaustive - gomodguard - govet - ineffassign - misspell + - modernize - nakedret - revive - sloglint @@ -32,7 +35,6 @@ linters: - unused - usestdlibvars - usetesting - - exhaustive exclusions: @@ -44,16 +46,9 @@ linters: - legacy - std-error-handling - rules: - # This rule is triggered for packages like 'util'. When changes to those packages - # occur it triggers this rule. This exclusion enables making changes to existing - # packages. - - linters: - - revive - text: 'var-naming: avoid meaningless package names' - warn-unused: true + # Keep sorted alphabetically settings: depguard: rules: @@ -67,6 +62,9 @@ linters: dupl: threshold: 400 + exhaustive: + default-signifies-exhaustive: true + gomodguard: blocked: modules: @@ -74,8 +72,21 @@ linters: recommendations: - github.com/evanphx/json-patch/v5 - exhaustive: - default-signifies-exhaustive: true + revive: + max-open-files: 2048 + enable-default-rules: true + rules: + - name: var-naming + arguments: + - ["ID"] # AllowList + - ["VM"] # DenyList + - - skip-initialism-name-checks: true + upper-case-const: true + skip-package-name-checks: true + skip-package-name-collision-with-go-std: true + extra-bad-package-names: + - helpers + - models run: timeout: 10m diff --git a/pkg/downloader/chart_downloader.go b/pkg/downloader/chart_downloader.go index d21a79335..9c26f925e 100644 --- a/pkg/downloader/chart_downloader.go +++ b/pkg/downloader/chart_downloader.go @@ -597,8 +597,8 @@ func loadRepoConfig(file string) (*repo.File, error) { // stripDigestAlgorithm removes the algorithm prefix (e.g., "sha256:") from a digest string. // If no prefix is present, the original string is returned unchanged. func stripDigestAlgorithm(digest string) string { - if idx := strings.Index(digest, ":"); idx >= 0 { - return digest[idx+1:] + if _, after, ok := strings.Cut(digest, ":"); ok { + return after } return digest }