From 1bcb59e36710e551c93908b09f4d8d15f0647151 Mon Sep 17 00:00:00 2001 From: Matthias Diester Date: Tue, 14 May 2024 12:00:04 +0200 Subject: [PATCH] Fix `gocritic` findings Fix linter findings. --- internal/cmd/events.go | 4 +--- internal/cmd/top.go | 2 +- internal/cmd/watch.go | 6 +++--- pkg/havener/kubexec.go | 1 - 4 files changed, 5 insertions(+), 8 deletions(-) diff --git a/internal/cmd/events.go b/internal/cmd/events.go index c1af5d3b..836843af 100644 --- a/internal/cmd/events.go +++ b/internal/cmd/events.go @@ -95,10 +95,8 @@ func retrieveClusterEvents(hvnr havener.Havener) error { for event := range watcher.ResultChan() { switch event.Type { case watch.Added, watch.Modified: - switch event.Object.(type) { + switch data := event.Object.(type) { case *corev1.Event: - data := *(event.Object.(*corev1.Event)) - resourceName := data.Name if strings.Contains(resourceName, ".") { parts := strings.Split(resourceName, ".") diff --git a/internal/cmd/top.go b/internal/cmd/top.go index 0da45e6e..2c6f7a6c 100644 --- a/internal/cmd/top.go +++ b/internal/cmd/top.go @@ -486,7 +486,7 @@ func renderProgressBar(value int64, max int64, caption string, text string, leng const symbol = "■" if !strings.HasSuffix(caption, " ") { - caption = caption + " " + caption += " " } if !strings.HasPrefix(text, " ") { diff --git a/internal/cmd/watch.go b/internal/cmd/watch.go index f0454c17..84478493 100644 --- a/internal/cmd/watch.go +++ b/internal/cmd/watch.go @@ -389,15 +389,15 @@ func humanReadableDuration(duration time.Duration) string { if seconds >= 60 { minutes = seconds / 60 - seconds = seconds % 60 + seconds %= 60 if minutes >= 60 { hours = minutes / 60 - minutes = minutes % 60 + minutes %= 60 if hours >= 24 { days = hours / 24 - hours = hours % 24 + hours %= 24 } } } diff --git a/pkg/havener/kubexec.go b/pkg/havener/kubexec.go index a517ef9c..20da8aef 100644 --- a/pkg/havener/kubexec.go +++ b/pkg/havener/kubexec.go @@ -81,7 +81,6 @@ func (h *Hvnr) PodExec(pod *corev1.Pod, container string, command []string, stdi } logf(Verbose, "Successfully executed command.") - return nil }