Run modernise on the project

This will be available in "go fix" within Go 1.26 but in the meantime:

go run golang.org/x/tools/gopls/internal/analysis/modernize/cmd/modernize@latest -fix -test ./...
This commit is contained in:
Jacalz
2025-09-17 22:28:16 +02:00
parent ee742cf34e
commit 534a7bfaaf
15 changed files with 26 additions and 38 deletions
+1 -4
View File
@@ -62,10 +62,7 @@ func (a *albumsPageAdapter) Route() controller.Route { return controller.AlbumsR
func (a *albumsPageAdapter) SortOrders() ([]string, int) {
orders := a.mp.AlbumSortOrders()
sortOrder := slices.Index(orders, a.cfg.SortOrder)
if sortOrder < 0 {
sortOrder = 0
}
sortOrder := max(slices.Index(orders, a.cfg.SortOrder), 0)
return util.LocalizeSlice(orders), sortOrder
}
+1 -4
View File
@@ -47,10 +47,7 @@ func (a *artistsPageAdapter) Route() controller.Route { return controller.Artist
func (a *artistsPageAdapter) SortOrders() ([]string, int) {
orders := a.mp.ArtistSortOrders()
sortOrder := slices.Index(orders, a.cfg.SortOrder)
if sortOrder < 0 {
sortOrder = 0
}
sortOrder := max(slices.Index(orders, a.cfg.SortOrder), 0)
return util.LocalizeSlice(orders), sortOrder
}
+1 -4
View File
@@ -106,10 +106,7 @@ func (s *SettingsDialog) createGeneralTab(canSaveQueueToServer bool) *container.
startupPage = widget.NewSelect(pages, func(_ string) {
s.config.Application.StartupPage = backend.SupportedStartupPages[startupPage.SelectedIndex()]
})
initialIdx := slices.Index(backend.SupportedStartupPages, s.config.Application.StartupPage)
if initialIdx < 0 {
initialIdx = 0
}
initialIdx := max(slices.Index(backend.SupportedStartupPages, s.config.Application.StartupPage), 0)
startupPage.SetSelectedIndex(initialIdx)
if startupPage.Selected == "" {
startupPage.SetSelectedIndex(0)
+2 -2
View File
@@ -23,7 +23,7 @@ func NewColumnsLayout(widths []float32) *ColumnsLayout {
func (c *ColumnsLayout) MinSize(objects []fyne.CanvasObject) fyne.Size {
var width float32
var height float32
for i := 0; i < len(objects); i++ {
for i := range objects {
if !objects[i].Visible() {
continue
}
@@ -56,7 +56,7 @@ func (c *ColumnsLayout) Layout(objects []fyne.CanvasObject, size fyne.Size) {
expandObjW := extraW / float32(expandObjCount)
var x float32
for i := 0; i < len(objects); i++ {
for i := range objects {
if !objects[i].Visible() {
continue
}
+1 -4
View File
@@ -341,10 +341,7 @@ func darkenColor(c color.Color, fraction float64) color.Color {
}
func brightenComponent(component uint32, fraction float64) uint32 {
brightened := component + uint32(float64(component)*fraction)
if brightened > 0xffff {
brightened = 0xffff
}
brightened := min(component+uint32(float64(component)*fraction), 0xffff)
return brightened
}
+2 -2
View File
@@ -236,7 +236,7 @@ type GenreFilterSubsection struct {
genreList []string
onChanged func([]string)
selectedGenres map[string]interface{}
selectedGenres map[string]any
selectedGenresMutex sync.RWMutex
filterText *widget.Entry
@@ -253,7 +253,7 @@ type GenreFilterSubsection struct {
func NewGenreFilterSubsection(onChanged func([]string), initialSelectedGenres []string) *GenreFilterSubsection {
g := &GenreFilterSubsection{
onChanged: onChanged,
selectedGenres: make(map[string]interface{}),
selectedGenres: make(map[string]any),
}
g.ExtendBaseWidget(g)
+2 -2
View File
@@ -45,7 +45,7 @@ func NewStarRating() *StarRating {
func (s *StarRating) createContainer() {
s.container = container.New(layout.NewCustomPaddedHBoxLayout(0))
var im *canvas.Image
for i := 0; i < 5; i++ {
for i := range 5 {
if s.IsDisabled {
im = canvas.NewImageFromResource(themedDisabledStarOutline)
} else if s.Rating > i {
@@ -126,7 +126,7 @@ func (s *StarRating) Refresh() {
if !s.holdRating && s.mouseHoverRating > 0 {
rating = s.mouseHoverRating
}
for i := 0; i < 5; i++ {
for i := range 5 {
im := s.container.Objects[i].(*canvas.Image)
im.SetMinSize(fyne.NewSize(s.StarSize, s.StarSize))
if s.IsDisabled {
+1 -1
View File
@@ -58,7 +58,7 @@ func (t *TracklistLoader) loadMoreTracks(num int) {
t.trackBuffer = make([]*mediaprovider.Track, 0, num)
}
t.trackBuffer = t.trackBuffer[:0]
for i := 0; i < num; i++ {
for range num {
tr := t.iter.Next()
if tr == nil {
t.done = true