golangci-lint: enable nilerr linter

cli/command/idresolver/idresolver.go:33:4: error is not nil (line 31) but it returns nil (nilerr)
    			return id, nil
    			^
    cli/command/idresolver/idresolver.go:45:4: error is not nil (line 43) but it returns nil (nilerr)
    			return id, nil
    			^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn 2023-11-20 14:53:40 +01:00
Родитель 7e9d2c78c6
Коммит 8bbdb93cf9
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 76698F39D527CE8C
2 изменённых файлов: 5 добавлений и 2 удалений

Просмотреть файл

@ -15,6 +15,7 @@ linters:
- megacheck
- misspell
- nakedret
- nilerr # Detects code that returns nil even if it checks that the error is not nil.
- predeclared
- revive
- staticcheck

Просмотреть файл

@ -30,7 +30,8 @@ func (r *IDResolver) get(ctx context.Context, t interface{}, id string) (string,
case swarm.Node:
node, _, err := r.client.NodeInspectWithRaw(ctx, id)
if err != nil {
return id, nil
// TODO(thaJeztah): should error-handling be more specific, or is it ok to ignore any error?
return id, nil //nolint:nilerr // ignore nil-error being returned, as this is a best-effort.
}
if node.Spec.Annotations.Name != "" {
return node.Spec.Annotations.Name, nil
@ -42,7 +43,8 @@ func (r *IDResolver) get(ctx context.Context, t interface{}, id string) (string,
case swarm.Service:
service, _, err := r.client.ServiceInspectWithRaw(ctx, id, types.ServiceInspectOptions{})
if err != nil {
return id, nil
// TODO(thaJeztah): should error-handling be more specific, or is it ok to ignore any error?
return id, nil //nolint:nilerr // ignore nil-error being returned, as this is a best-effort.
}
return service.Spec.Annotations.Name, nil
default: