Merge pull request #5836 from thaJeztah/nakedret

golangci-lint: fix invalid nakedret config, disallow for any func length
This commit is contained in:
Sebastiaan van Stijn 2025-02-18 13:15:28 +01:00 committed by GitHub
commit bfd49b1ec3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 15 additions and 9 deletions

View File

@ -16,7 +16,7 @@ linters:
- govet - govet
- ineffassign - ineffassign
- misspell # Detects commonly misspelled English words in comments. - misspell # Detects commonly misspelled English words in comments.
- nakedret - nakedret # Detects uses of naked returns.
- nilerr # Detects code that returns nil even if it checks that the error is not nil. - nilerr # Detects code that returns nil even if it checks that the error is not nil.
- nolintlint # Detects ill-formed or insufficient nolint directives. - nolintlint # Detects ill-formed or insufficient nolint directives.
- perfsprint # Detects fmt.Sprintf uses that can be replaced with a faster alternative. - perfsprint # Detects fmt.Sprintf uses that can be replaced with a faster alternative.
@ -82,8 +82,9 @@ linters-settings:
lll: lll:
line-length: 200 line-length: 200
nakedret: nakedret:
command: nakedret # Disallow naked returns if func has more lines of code than this setting.
pattern: ^(?P<path>.*?\\.go):(?P<line>\\d+)\\s*(?P<message>.*)$ # Default: 30
max-func-lines: 0
revive: revive:
rules: rules:

View File

@ -201,9 +201,10 @@ func runCopy(ctx context.Context, dockerCli command.Cli, opts copyOptions) error
} }
} }
func resolveLocalPath(localPath string) (absPath string, err error) { func resolveLocalPath(localPath string) (absPath string, _ error) {
if absPath, err = filepath.Abs(localPath); err != nil { absPath, err := filepath.Abs(localPath)
return if err != nil {
return "", err
} }
return archive.PreserveTrailingDotOrSeparator(absPath, localPath), nil return archive.PreserveTrailingDotOrSeparator(absPath, localPath), nil
} }

View File

@ -56,15 +56,19 @@ type Source struct {
} }
// GetClaims returns claims from an access token without verification. // GetClaims returns claims from an access token without verification.
func GetClaims(accessToken string) (claims Claims, err error) { func GetClaims(accessToken string) (Claims, error) {
token, err := parseSigned(accessToken) token, err := parseSigned(accessToken)
if err != nil { if err != nil {
return return Claims{}, err
} }
var claims Claims
err = token.UnsafeClaimsWithoutVerification(&claims) err = token.UnsafeClaimsWithoutVerification(&claims)
if err != nil {
return Claims{}, err
}
return return claims, nil
} }
// allowedSignatureAlgorithms is a list of allowed signature algorithms for JWTs. // allowedSignatureAlgorithms is a list of allowed signature algorithms for JWTs.