From e31a078e6e0667dde72ff3bf4b5dfb625127076f Mon Sep 17 00:00:00 2001 From: Matthieu MOREL Date: Fri, 6 Mar 2026 15:54:33 +0100 Subject: [PATCH] chore: enable modernize linter (#31860) Signed-off-by: Matthieu MOREL --- .github/env | 2 +- .golangci.yml | 29 ++++++++++++++++++++--------- pkg/downloader/chart_downloader.go | 4 ++-- 3 files changed, 23 insertions(+), 12 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 d808421a0..536b4b212 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 - nolintlint - revive @@ -33,7 +36,6 @@ linters: - unused - usestdlibvars - usetesting - - exhaustive exclusions: @@ -45,16 +47,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: @@ -81,6 +76,22 @@ linters: nolintlint: require-specific: 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 }