From c6efac247cb78c91fa1c18cf8b9597a6ce81a5c5 Mon Sep 17 00:00:00 2001 From: Jacalz Date: Mon, 30 Sep 2024 21:29:17 +0200 Subject: [PATCH] Update CI and code to use Staticcheck v0.5.1 This fixes a few code errors that slipped through review (thankfully now handled by Staticcheck for us) and makes sure we are using the latest version. --- .github/workflows/static_analysis.yml | 2 +- cmd/fyne/internal/mobile/binres/binres_test.go | 2 +- widget/check_group.go | 2 +- widget/list.go | 4 ++-- widget/radio_group.go | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/static_analysis.yml b/.github/workflows/static_analysis.yml index 6acb8cb6fa..0a13b58c9b 100644 --- a/.github/workflows/static_analysis.yml +++ b/.github/workflows/static_analysis.yml @@ -33,7 +33,7 @@ jobs: run: | go install golang.org/x/tools/cmd/goimports@latest go install github.com/fzipp/gocyclo/cmd/gocyclo@latest - go install honnef.co/go/tools/cmd/staticcheck@v0.4.6 + go install honnef.co/go/tools/cmd/staticcheck@v0.5.1 go install github.com/mattn/goveralls@latest - name: Vet diff --git a/cmd/fyne/internal/mobile/binres/binres_test.go b/cmd/fyne/internal/mobile/binres/binres_test.go index f6d5e8e6e3..92fdb67446 100644 --- a/cmd/fyne/internal/mobile/binres/binres_test.go +++ b/cmd/fyne/internal/mobile/binres/binres_test.go @@ -246,7 +246,7 @@ func compareElements(have, want *XML) error { } } if buf.Len() > 0 { - return fmt.Errorf(buf.String()) + return errors.New(buf.String()) } return nil } diff --git a/widget/check_group.go b/widget/check_group.go index 6fc258485e..e2725b35ed 100644 --- a/widget/check_group.go +++ b/widget/check_group.go @@ -182,7 +182,7 @@ type checkGroupRenderer struct { // Layout the components of the checks widget func (r *checkGroupRenderer) Layout(_ fyne.Size) { count := 1 - if r.items != nil && len(r.items) > 0 { + if len(r.items) > 0 { count = len(r.items) } var itemHeight, itemWidth float32 diff --git a/widget/list.go b/widget/list.go index d640e13cb7..f51d6e3c65 100644 --- a/widget/list.go +++ b/widget/list.go @@ -169,7 +169,7 @@ func (l *List) scrollTo(id ListItemID) { separatorThickness := l.Theme().Size(theme.SizeNamePadding) y := float32(0) lastItemHeight := l.itemMin.Height - if l.itemHeights == nil || len(l.itemHeights) == 0 { + if len(l.itemHeights) == 0 { y = (float32(id) * l.itemMin.Height) + (float32(id) * separatorThickness) } else { for i := 0; i < id; i++ { @@ -368,7 +368,7 @@ func (l *List) contentMinSize() fyne.Size { } items := l.Length() - if l.itemHeights == nil || len(l.itemHeights) == 0 { + if len(l.itemHeights) == 0 { return fyne.NewSize(l.itemMin.Width, (l.itemMin.Height+separatorThickness)*float32(items)-separatorThickness) } diff --git a/widget/radio_group.go b/widget/radio_group.go index 51944a6740..3cf9bcb11f 100644 --- a/widget/radio_group.go +++ b/widget/radio_group.go @@ -156,7 +156,7 @@ type radioGroupRenderer struct { // Layout the components of the radio widget func (r *radioGroupRenderer) Layout(_ fyne.Size) { count := 1 - if r.items != nil && len(r.items) > 0 { + if len(r.items) > 0 { count = len(r.items) } var itemHeight, itemWidth float32