chore: enable modernize linter (#31860)

Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
pull/11250/merge
Matthieu MOREL 4 days ago committed by GitHub
parent b4f4c4c2dd
commit e31a078e6e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

2
.github/env vendored

@ -1,2 +1,2 @@
GOLANG_VERSION=1.25
GOLANGCI_LINT_VERSION=v2.5.0
GOLANGCI_LINT_VERSION=v2.10.1

@ -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

@ -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
}

Loading…
Cancel
Save