fix(go): collapse struct-literal copies to type conversions (S1016)
staticcheck S1016 in the new golangci-lint v2 flagged four sites
copying field-by-field between two types with identical struct
shapes. Direct type conversion is the canonical form:
- internal/library/scanrun.go:
- LibraryStageTallies copy from Stats → LibraryStageTallies(lastStats)
- MBIDBackfillStageTallies copy from BackfillMBIDsResult →
MBIDBackfillStageTallies(lastRes)
- internal/recommendation/home.go:
- dbq.ListRediscoverAlbumsForUserRow copy from the Fallback row
type → dbq.ListRediscoverAlbumsForUserRow(r)
- Same pattern for the Artists rediscover pair.
No behavior change; the underlying struct shapes are identical
(staticcheck verified the conversion is valid). Net -18 +4 lines.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -100,11 +100,7 @@ func RunScan(
|
|||||||
var lastStats Stats
|
var lastStats Stats
|
||||||
libPub := newStagePublisher(ctx, 500, time.Second,
|
libPub := newStagePublisher(ctx, 500, time.Second,
|
||||||
func() []byte {
|
func() []byte {
|
||||||
blob, _ := json.Marshal(LibraryStageTallies{
|
blob, _ := json.Marshal(LibraryStageTallies(lastStats))
|
||||||
Scanned: lastStats.Scanned, Added: lastStats.Added,
|
|
||||||
Updated: lastStats.Updated, Skipped: lastStats.Skipped,
|
|
||||||
Errored: lastStats.Errored,
|
|
||||||
})
|
|
||||||
return blob
|
return blob
|
||||||
},
|
},
|
||||||
func(blob []byte) error {
|
func(blob []byte) error {
|
||||||
@@ -131,10 +127,7 @@ func RunScan(
|
|||||||
var lastRes BackfillMBIDsResult
|
var lastRes BackfillMBIDsResult
|
||||||
bfPub := newStagePublisher(ctx, 500, time.Second,
|
bfPub := newStagePublisher(ctx, 500, time.Second,
|
||||||
func() []byte {
|
func() []byte {
|
||||||
blob, _ := json.Marshal(MBIDBackfillStageTallies{
|
blob, _ := json.Marshal(MBIDBackfillStageTallies(lastRes))
|
||||||
Processed: lastRes.Processed, Healed: lastRes.Healed,
|
|
||||||
Skipped: lastRes.Skipped, Duplicates: lastRes.Duplicates,
|
|
||||||
})
|
|
||||||
return blob
|
return blob
|
||||||
},
|
},
|
||||||
func(blob []byte) error {
|
func(blob []byte) error {
|
||||||
|
|||||||
@@ -145,10 +145,7 @@ func loadRediscoverAlbums(ctx context.Context, q *dbq.Queries, userID pgtype.UUI
|
|||||||
if _, dup := seen[r.Album.ID]; dup {
|
if _, dup := seen[r.Album.ID]; dup {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
primary = append(primary, dbq.ListRediscoverAlbumsForUserRow{
|
primary = append(primary, dbq.ListRediscoverAlbumsForUserRow(r))
|
||||||
Album: r.Album,
|
|
||||||
ArtistName: r.ArtistName,
|
|
||||||
})
|
|
||||||
if len(primary) >= HomeRediscoverLimit {
|
if len(primary) >= HomeRediscoverLimit {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
@@ -181,11 +178,7 @@ func loadRediscoverArtists(ctx context.Context, q *dbq.Queries, userID pgtype.UU
|
|||||||
if _, dup := seen[r.Artist.ID]; dup {
|
if _, dup := seen[r.Artist.ID]; dup {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
primary = append(primary, dbq.ListRediscoverArtistsForUserRow{
|
primary = append(primary, dbq.ListRediscoverArtistsForUserRow(r))
|
||||||
Artist: r.Artist,
|
|
||||||
CoverAlbumID: r.CoverAlbumID,
|
|
||||||
AlbumCount: r.AlbumCount,
|
|
||||||
})
|
|
||||||
if len(primary) >= HomeRediscoverLimit {
|
if len(primary) >= HomeRediscoverLimit {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user