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:
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user