From f69bda989e3ecad1178917e42aee23304c05617f Mon Sep 17 00:00:00 2001 From: Daniel Milde Date: Sat, 30 Nov 2024 23:01:49 +0100 Subject: [PATCH] fix: fmt --- pkg/analyze/top.go | 14 ++++++-------- stdout/stdout.go | 14 ++++++++------ stdout/stdout_linux_test.go | 2 +- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/pkg/analyze/top.go b/pkg/analyze/top.go index 55814747c..b7e569c7e 100644 --- a/pkg/analyze/top.go +++ b/pkg/analyze/top.go @@ -25,14 +25,12 @@ func (tl *TopList) Add(file fs.Item) { if file.GetSize() > tl.MinSize { tl.MinSize = file.GetSize() } - } else { - if file.GetSize() > tl.MinSize { - tl.Items = append(tl.Items, file) - tl.MinSize = file.GetSize() - if len(tl.Items) > tl.Count { - sort.Sort(fs.ByApparentSize(tl.Items)) - tl.Items = tl.Items[1:] - } + } else if file.GetSize() > tl.MinSize { + tl.Items = append(tl.Items, file) + tl.MinSize = file.GetSize() + if len(tl.Items) > tl.Count { + sort.Sort(fs.ByApparentSize(tl.Items)) + tl.Items = tl.Items[1:] } } } diff --git a/stdout/stdout.go b/stdout/stdout.go index 4d00d3eba..84dfcacef 100644 --- a/stdout/stdout.go +++ b/stdout/stdout.go @@ -170,11 +170,12 @@ func (ui *UI) AnalyzePath(path string, _ fs.Item) error { wait.Wait() - if ui.top > 0 { + switch { + case ui.top > 0: ui.printTopFiles(dir) - } else if ui.summarize { + case ui.summarize: ui.printTotalItem(dir) - } else { + default: ui.showDir(dir) } @@ -192,11 +193,12 @@ func (ui *UI) ReadFromStorage(storagePath, path string) error { return err } - if ui.top > 0 { + switch { + case ui.top > 0: ui.printTopFiles(dir) - } else if ui.summarize { + case ui.summarize: ui.printTotalItem(dir) - } else { + default: ui.showDir(dir) } return nil diff --git a/stdout/stdout_linux_test.go b/stdout/stdout_linux_test.go index 4a47daed2..781d11bb1 100644 --- a/stdout/stdout_linux_test.go +++ b/stdout/stdout_linux_test.go @@ -21,7 +21,7 @@ func TestShowDevicesWithErr(t *testing.T) { output := bytes.NewBuffer(make([]byte, 10)) getter := device.LinuxDevicesInfoGetter{MountsPath: "/xyzxyz"} - ui := CreateStdoutUI(output, false, true, false, false, false, false, false, false) + ui := CreateStdoutUI(output, false, true, false, false, false, false, false, false, 0) err := ui.ListDevices(getter) assert.Contains(t, err.Error(), "no such file")