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:
@@ -46,7 +46,7 @@ type ImageManager struct {
|
|||||||
maxOnDiskCacheSizeBytes int64
|
maxOnDiskCacheSizeBytes int64
|
||||||
filesWrittenSinceLastPrune bool
|
filesWrittenSinceLastPrune bool
|
||||||
|
|
||||||
serverFetchSema chan interface{}
|
serverFetchSema chan any
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewImageManager returns a new ImageManager.
|
// NewImageManager returns a new ImageManager.
|
||||||
@@ -64,7 +64,7 @@ func NewImageManager(ctx context.Context, s *ServerManager, baseCacheDir string)
|
|||||||
DefaultTTL: 1 * time.Minute,
|
DefaultTTL: 1 * time.Minute,
|
||||||
},
|
},
|
||||||
maxOnDiskCacheSizeBytes: defaultDiskCacheSizeBytes,
|
maxOnDiskCacheSizeBytes: defaultDiskCacheSizeBytes,
|
||||||
serverFetchSema: make(chan interface{}, maxConcurrentServerFetches),
|
serverFetchSema: make(chan any, maxConcurrentServerFetches),
|
||||||
}
|
}
|
||||||
s.OnLogout(func() {
|
s.OnLogout(func() {
|
||||||
i.thumbnailCache.Clear()
|
i.thumbnailCache.Clear()
|
||||||
|
|||||||
@@ -144,7 +144,7 @@ func (s *serverImpl) createHandler() http.Handler {
|
|||||||
search = strings.ToLower(search)
|
search = strings.ToLower(search)
|
||||||
|
|
||||||
filtered := make([]mediaprovider.Playlist, 0)
|
filtered := make([]mediaprovider.Playlist, 0)
|
||||||
for i := 0; i < len(all); i++ {
|
for i := range all {
|
||||||
playlist := all[i]
|
playlist := all[i]
|
||||||
name := strings.ReplaceAll(playlist.Name, " ", "")
|
name := strings.ReplaceAll(playlist.Name, " ", "")
|
||||||
name = strings.ToLower(name)
|
name = strings.ToLower(name)
|
||||||
|
|||||||
@@ -344,7 +344,7 @@ func (j *jellyfinMediaProvider) SetFavorite(params mediaprovider.RatingFavoriteP
|
|||||||
}
|
}
|
||||||
|
|
||||||
numBatches := int(math.Ceil(float64(len(allIDs)) / float64(batchSize)))
|
numBatches := int(math.Ceil(float64(len(allIDs)) / float64(batchSize)))
|
||||||
for i := 0; i < numBatches; i++ {
|
for i := range numBatches {
|
||||||
var wg sync.WaitGroup
|
var wg sync.WaitGroup
|
||||||
batchSetFavorite(i*batchSize, &wg)
|
batchSetFavorite(i*batchSize, &wg)
|
||||||
wg.Wait()
|
wg.Wait()
|
||||||
|
|||||||
@@ -342,7 +342,7 @@ func (s *subsonicMediaProvider) SetRating(params mediaprovider.RatingFavoritePar
|
|||||||
}
|
}
|
||||||
|
|
||||||
numBatches := int(math.Ceil(float64(len(params.TrackIDs)) / float64(batchSize)))
|
numBatches := int(math.Ceil(float64(len(params.TrackIDs)) / float64(batchSize)))
|
||||||
for i := 0; i < numBatches; i++ {
|
for i := range numBatches {
|
||||||
var wg sync.WaitGroup
|
var wg sync.WaitGroup
|
||||||
batchSetRating(i*batchSize, &wg)
|
batchSetRating(i*batchSize, &wg)
|
||||||
wg.Wait()
|
wg.Wait()
|
||||||
|
|||||||
@@ -498,7 +498,7 @@ func (p *PlaybackManager) PlayRandomAlbums(genreName string) error {
|
|||||||
}
|
}
|
||||||
iter := mp.IterateAlbums(mediaprovider.AlbumSortRandom, mediaprovider.NewAlbumFilter(options))
|
iter := mp.IterateAlbums(mediaprovider.AlbumSortRandom, mediaprovider.NewAlbumFilter(options))
|
||||||
insertMode := Replace
|
insertMode := Replace
|
||||||
for i := 0; i < 20; i++ {
|
for i := range 20 {
|
||||||
al := iter.Next()
|
al := iter.Next()
|
||||||
if al == nil {
|
if al == nil {
|
||||||
break
|
break
|
||||||
|
|||||||
@@ -618,7 +618,7 @@ func (d *DLNAPlayer) lookupProxyURL(key string) (string, bool) {
|
|||||||
d.proxyURLLock.Lock()
|
d.proxyURLLock.Lock()
|
||||||
defer d.proxyURLLock.Unlock()
|
defer d.proxyURLLock.Unlock()
|
||||||
|
|
||||||
for i := 0; i < len(d.proxyURLs); i++ {
|
for i := range len(d.proxyURLs) {
|
||||||
if d.proxyURLs[i].key == key {
|
if d.proxyURLs[i].key == key {
|
||||||
url := d.proxyURLs[i].url
|
url := d.proxyURLs[i].url
|
||||||
// Move accessed entry to the most recent position
|
// Move accessed entry to the most recent position
|
||||||
@@ -632,7 +632,7 @@ func (d *DLNAPlayer) lookupProxyURL(key string) (string, bool) {
|
|||||||
|
|
||||||
func (d *DLNAPlayer) _updateProxyURL(key, url string) {
|
func (d *DLNAPlayer) _updateProxyURL(key, url string) {
|
||||||
// Check if the key already exists, and if so, move it to the most recently used position
|
// Check if the key already exists, and if so, move it to the most recently used position
|
||||||
for i := 0; i < len(d.proxyURLs); i++ {
|
for i := range len(d.proxyURLs) {
|
||||||
if d.proxyURLs[i].key == key {
|
if d.proxyURLs[i].key == key {
|
||||||
if i < len(d.proxyURLs)-1 {
|
if i < len(d.proxyURLs)-1 {
|
||||||
// Shift elements to the left from found position to the end
|
// Shift elements to the left from found position to the end
|
||||||
@@ -652,19 +652,19 @@ func (d *DLNAPlayer) _updateProxyURL(key, url string) {
|
|||||||
|
|
||||||
type retryLogger struct{}
|
type retryLogger struct{}
|
||||||
|
|
||||||
func (retryLogger) Error(msg string, keysAndValues ...interface{}) {
|
func (retryLogger) Error(msg string, keysAndValues ...any) {
|
||||||
log.Println(msg, keysAndValues)
|
log.Println(msg, keysAndValues)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (retryLogger) Info(msg string, keysAndValues ...interface{}) {
|
func (retryLogger) Info(msg string, keysAndValues ...any) {
|
||||||
log.Println(msg, keysAndValues)
|
log.Println(msg, keysAndValues)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (retryLogger) Warn(msg string, keysAndValues ...interface{}) {
|
func (retryLogger) Warn(msg string, keysAndValues ...any) {
|
||||||
log.Println(msg, keysAndValues)
|
log.Println(msg, keysAndValues)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (retryLogger) Debug(msg string, keysAndValues ...interface{}) {
|
func (retryLogger) Debug(msg string, keysAndValues ...any) {
|
||||||
// log only retries, not every request
|
// log only retries, not every request
|
||||||
if strings.Contains(msg, "retrying request") {
|
if strings.Contains(msg, "retrying request") {
|
||||||
log.Println(msg, keysAndValues)
|
log.Println(msg, keysAndValues)
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ func (w *WaveformImageJob) Get() *WaveformImage {
|
|||||||
result := NewWaveformImage()
|
result := NewWaveformImage()
|
||||||
|
|
||||||
// Copy each scanline from w.img to result
|
// Copy each scanline from w.img to result
|
||||||
for y := 0; y < height; y++ {
|
for y := range height {
|
||||||
srcOffset := w.img.PixOffset(0, y)
|
srcOffset := w.img.PixOffset(0, y)
|
||||||
dstOffset := result.PixOffset(0, y)
|
dstOffset := result.PixOffset(0, y)
|
||||||
copy(result.Pix[dstOffset:dstOffset+w.progress*4], w.img.Pix[srcOffset:srcOffset+w.progress*4])
|
copy(result.Pix[dstOffset:dstOffset+w.progress*4], w.img.Pix[srcOffset:srcOffset+w.progress*4])
|
||||||
@@ -226,7 +226,7 @@ func generateWaveformImage(ctx context.Context, data *waveformData, job *Wavefor
|
|||||||
opaqueColor := color.NRGBA{R: 255, G: 255, B: 255, A: 255}
|
opaqueColor := color.NRGBA{R: 255, G: 255, B: 255, A: 255}
|
||||||
translucentColor := color.NRGBA{R: 255, G: 255, B: 255, A: 128}
|
translucentColor := color.NRGBA{R: 255, G: 255, B: 255, A: 128}
|
||||||
|
|
||||||
for x := 0; x < 1024; x++ {
|
for x := range 1024 {
|
||||||
for data.progress <= x {
|
for data.progress <= x {
|
||||||
if data.done {
|
if data.done {
|
||||||
return
|
return
|
||||||
@@ -341,7 +341,7 @@ func analyzeWavFile(ctx context.Context, transcodeFile string, data *waveformDat
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Process samples
|
// Process samples
|
||||||
for i := 0; i < n; i++ {
|
for i := range n {
|
||||||
sample := float64(buf.Data[i]) / float64(1<<15) // Normalize to [-1, 1]
|
sample := float64(buf.Data[i]) / float64(1<<15) // Normalize to [-1, 1]
|
||||||
chunkSamples = append(chunkSamples, sample)
|
chunkSamples = append(chunkSamples, sample)
|
||||||
|
|
||||||
|
|||||||
@@ -62,10 +62,7 @@ func (a *albumsPageAdapter) Route() controller.Route { return controller.AlbumsR
|
|||||||
|
|
||||||
func (a *albumsPageAdapter) SortOrders() ([]string, int) {
|
func (a *albumsPageAdapter) SortOrders() ([]string, int) {
|
||||||
orders := a.mp.AlbumSortOrders()
|
orders := a.mp.AlbumSortOrders()
|
||||||
sortOrder := slices.Index(orders, a.cfg.SortOrder)
|
sortOrder := max(slices.Index(orders, a.cfg.SortOrder), 0)
|
||||||
if sortOrder < 0 {
|
|
||||||
sortOrder = 0
|
|
||||||
}
|
|
||||||
|
|
||||||
return util.LocalizeSlice(orders), sortOrder
|
return util.LocalizeSlice(orders), sortOrder
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,10 +47,7 @@ func (a *artistsPageAdapter) Route() controller.Route { return controller.Artist
|
|||||||
|
|
||||||
func (a *artistsPageAdapter) SortOrders() ([]string, int) {
|
func (a *artistsPageAdapter) SortOrders() ([]string, int) {
|
||||||
orders := a.mp.ArtistSortOrders()
|
orders := a.mp.ArtistSortOrders()
|
||||||
sortOrder := slices.Index(orders, a.cfg.SortOrder)
|
sortOrder := max(slices.Index(orders, a.cfg.SortOrder), 0)
|
||||||
if sortOrder < 0 {
|
|
||||||
sortOrder = 0
|
|
||||||
}
|
|
||||||
|
|
||||||
return util.LocalizeSlice(orders), sortOrder
|
return util.LocalizeSlice(orders), sortOrder
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -106,10 +106,7 @@ func (s *SettingsDialog) createGeneralTab(canSaveQueueToServer bool) *container.
|
|||||||
startupPage = widget.NewSelect(pages, func(_ string) {
|
startupPage = widget.NewSelect(pages, func(_ string) {
|
||||||
s.config.Application.StartupPage = backend.SupportedStartupPages[startupPage.SelectedIndex()]
|
s.config.Application.StartupPage = backend.SupportedStartupPages[startupPage.SelectedIndex()]
|
||||||
})
|
})
|
||||||
initialIdx := slices.Index(backend.SupportedStartupPages, s.config.Application.StartupPage)
|
initialIdx := max(slices.Index(backend.SupportedStartupPages, s.config.Application.StartupPage), 0)
|
||||||
if initialIdx < 0 {
|
|
||||||
initialIdx = 0
|
|
||||||
}
|
|
||||||
startupPage.SetSelectedIndex(initialIdx)
|
startupPage.SetSelectedIndex(initialIdx)
|
||||||
if startupPage.Selected == "" {
|
if startupPage.Selected == "" {
|
||||||
startupPage.SetSelectedIndex(0)
|
startupPage.SetSelectedIndex(0)
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ func NewColumnsLayout(widths []float32) *ColumnsLayout {
|
|||||||
func (c *ColumnsLayout) MinSize(objects []fyne.CanvasObject) fyne.Size {
|
func (c *ColumnsLayout) MinSize(objects []fyne.CanvasObject) fyne.Size {
|
||||||
var width float32
|
var width float32
|
||||||
var height float32
|
var height float32
|
||||||
for i := 0; i < len(objects); i++ {
|
for i := range objects {
|
||||||
if !objects[i].Visible() {
|
if !objects[i].Visible() {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@@ -56,7 +56,7 @@ func (c *ColumnsLayout) Layout(objects []fyne.CanvasObject, size fyne.Size) {
|
|||||||
expandObjW := extraW / float32(expandObjCount)
|
expandObjW := extraW / float32(expandObjCount)
|
||||||
|
|
||||||
var x float32
|
var x float32
|
||||||
for i := 0; i < len(objects); i++ {
|
for i := range objects {
|
||||||
if !objects[i].Visible() {
|
if !objects[i].Visible() {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-4
@@ -341,10 +341,7 @@ func darkenColor(c color.Color, fraction float64) color.Color {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func brightenComponent(component uint32, fraction float64) uint32 {
|
func brightenComponent(component uint32, fraction float64) uint32 {
|
||||||
brightened := component + uint32(float64(component)*fraction)
|
brightened := min(component+uint32(float64(component)*fraction), 0xffff)
|
||||||
if brightened > 0xffff {
|
|
||||||
brightened = 0xffff
|
|
||||||
}
|
|
||||||
return brightened
|
return brightened
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -236,7 +236,7 @@ type GenreFilterSubsection struct {
|
|||||||
genreList []string
|
genreList []string
|
||||||
onChanged func([]string)
|
onChanged func([]string)
|
||||||
|
|
||||||
selectedGenres map[string]interface{}
|
selectedGenres map[string]any
|
||||||
selectedGenresMutex sync.RWMutex
|
selectedGenresMutex sync.RWMutex
|
||||||
|
|
||||||
filterText *widget.Entry
|
filterText *widget.Entry
|
||||||
@@ -253,7 +253,7 @@ type GenreFilterSubsection struct {
|
|||||||
func NewGenreFilterSubsection(onChanged func([]string), initialSelectedGenres []string) *GenreFilterSubsection {
|
func NewGenreFilterSubsection(onChanged func([]string), initialSelectedGenres []string) *GenreFilterSubsection {
|
||||||
g := &GenreFilterSubsection{
|
g := &GenreFilterSubsection{
|
||||||
onChanged: onChanged,
|
onChanged: onChanged,
|
||||||
selectedGenres: make(map[string]interface{}),
|
selectedGenres: make(map[string]any),
|
||||||
}
|
}
|
||||||
g.ExtendBaseWidget(g)
|
g.ExtendBaseWidget(g)
|
||||||
|
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ func NewStarRating() *StarRating {
|
|||||||
func (s *StarRating) createContainer() {
|
func (s *StarRating) createContainer() {
|
||||||
s.container = container.New(layout.NewCustomPaddedHBoxLayout(0))
|
s.container = container.New(layout.NewCustomPaddedHBoxLayout(0))
|
||||||
var im *canvas.Image
|
var im *canvas.Image
|
||||||
for i := 0; i < 5; i++ {
|
for i := range 5 {
|
||||||
if s.IsDisabled {
|
if s.IsDisabled {
|
||||||
im = canvas.NewImageFromResource(themedDisabledStarOutline)
|
im = canvas.NewImageFromResource(themedDisabledStarOutline)
|
||||||
} else if s.Rating > i {
|
} else if s.Rating > i {
|
||||||
@@ -126,7 +126,7 @@ func (s *StarRating) Refresh() {
|
|||||||
if !s.holdRating && s.mouseHoverRating > 0 {
|
if !s.holdRating && s.mouseHoverRating > 0 {
|
||||||
rating = s.mouseHoverRating
|
rating = s.mouseHoverRating
|
||||||
}
|
}
|
||||||
for i := 0; i < 5; i++ {
|
for i := range 5 {
|
||||||
im := s.container.Objects[i].(*canvas.Image)
|
im := s.container.Objects[i].(*canvas.Image)
|
||||||
im.SetMinSize(fyne.NewSize(s.StarSize, s.StarSize))
|
im.SetMinSize(fyne.NewSize(s.StarSize, s.StarSize))
|
||||||
if s.IsDisabled {
|
if s.IsDisabled {
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ func (t *TracklistLoader) loadMoreTracks(num int) {
|
|||||||
t.trackBuffer = make([]*mediaprovider.Track, 0, num)
|
t.trackBuffer = make([]*mediaprovider.Track, 0, num)
|
||||||
}
|
}
|
||||||
t.trackBuffer = t.trackBuffer[:0]
|
t.trackBuffer = t.trackBuffer[:0]
|
||||||
for i := 0; i < num; i++ {
|
for range num {
|
||||||
tr := t.iter.Next()
|
tr := t.iter.Next()
|
||||||
if tr == nil {
|
if tr == nil {
|
||||||
t.done = true
|
t.done = true
|
||||||
|
|||||||
Reference in New Issue
Block a user