golangci-lint: enable exhaustive linter

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn 2025-05-19 19:10:53 +02:00
parent b64d9b3b19
commit d65f0c9bbf
No known key found for this signature in database
GPG Key ID: 76698F39D527CE8C
4 changed files with 8 additions and 6 deletions

View File

@ -34,6 +34,7 @@ linters:
- durationcheck # Detect cases where two time.Duration values are being multiplied in possibly erroneous ways. - durationcheck # Detect cases where two time.Duration values are being multiplied in possibly erroneous ways.
- errcheck - errcheck
- errchkjson # Detects unsupported types passed to json encoding functions and reports if checks for the returned error can be omitted. - errchkjson # Detects unsupported types passed to json encoding functions and reports if checks for the returned error can be omitted.
- exhaustive # Detects missing options in enum switch statements.
- forbidigo - forbidigo
- gocritic # Metalinter; detects bugs, performance, and styling issues. - gocritic # Metalinter; detects bugs, performance, and styling issues.
- gocyclo - gocyclo

View File

@ -81,7 +81,7 @@ func addPluginCandidatesFromDir(res map[string][]string, d string) {
return return
} }
for _, dentry := range dentries { for _, dentry := range dentries {
switch dentry.Type() & os.ModeType { switch dentry.Type() & os.ModeType { //nolint:exhaustive,nolintlint // no need to include all possible file-modes in this list
case 0, os.ModeSymlink: case 0, os.ModeSymlink:
// Regular file or symlink, keep going // Regular file or symlink, keep going
default: default:

View File

@ -20,6 +20,8 @@ func charWidth(r rune) int {
switch width.LookupRune(r).Kind() { switch width.LookupRune(r).Kind() {
case width.EastAsianWide, width.EastAsianFullwidth: case width.EastAsianWide, width.EastAsianFullwidth:
return 2 return 2
case width.Neutral, width.EastAsianAmbiguous, width.EastAsianNarrow, width.EastAsianHalfwidth:
return 1
default: default:
return 1 return 1
} }

View File

@ -50,7 +50,7 @@ func runUnlock(ctx context.Context, dockerCli command.Cli) error {
return errors.New("Error: This node is not part of a swarm") return errors.New("Error: This node is not part of a swarm")
case swarm.LocalNodeStateLocked: case swarm.LocalNodeStateLocked:
break break
default: case swarm.LocalNodeStatePending, swarm.LocalNodeStateActive, swarm.LocalNodeStateError:
return errors.New("Error: swarm is not locked") return errors.New("Error: swarm is not locked")
} }
@ -58,11 +58,10 @@ func runUnlock(ctx context.Context, dockerCli command.Cli) error {
if err != nil { if err != nil {
return err return err
} }
req := swarm.UnlockRequest{
UnlockKey: key,
}
return client.SwarmUnlock(ctx, req) return client.SwarmUnlock(ctx, swarm.UnlockRequest{
UnlockKey: key,
})
} }
func readKey(in *streams.In, prompt string) (string, error) { func readKey(in *streams.In, prompt string) (string, error) {