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
|
||||
libPub := newStagePublisher(ctx, 500, time.Second,
|
||||
func() []byte {
|
||||
blob, _ := json.Marshal(LibraryStageTallies{
|
||||
Scanned: lastStats.Scanned, Added: lastStats.Added,
|
||||
Updated: lastStats.Updated, Skipped: lastStats.Skipped,
|
||||
Errored: lastStats.Errored,
|
||||
})
|
||||
blob, _ := json.Marshal(LibraryStageTallies(lastStats))
|
||||
return blob
|
||||
},
|
||||
func(blob []byte) error {
|
||||
@@ -131,10 +127,7 @@ func RunScan(
|
||||
var lastRes BackfillMBIDsResult
|
||||
bfPub := newStagePublisher(ctx, 500, time.Second,
|
||||
func() []byte {
|
||||
blob, _ := json.Marshal(MBIDBackfillStageTallies{
|
||||
Processed: lastRes.Processed, Healed: lastRes.Healed,
|
||||
Skipped: lastRes.Skipped, Duplicates: lastRes.Duplicates,
|
||||
})
|
||||
blob, _ := json.Marshal(MBIDBackfillStageTallies(lastRes))
|
||||
return blob
|
||||
},
|
||||
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 {
|
||||
continue
|
||||
}
|
||||
primary = append(primary, dbq.ListRediscoverAlbumsForUserRow{
|
||||
Album: r.Album,
|
||||
ArtistName: r.ArtistName,
|
||||
})
|
||||
primary = append(primary, dbq.ListRediscoverAlbumsForUserRow(r))
|
||||
if len(primary) >= HomeRediscoverLimit {
|
||||
break
|
||||
}
|
||||
@@ -181,11 +178,7 @@ func loadRediscoverArtists(ctx context.Context, q *dbq.Queries, userID pgtype.UU
|
||||
if _, dup := seen[r.Artist.ID]; dup {
|
||||
continue
|
||||
}
|
||||
primary = append(primary, dbq.ListRediscoverArtistsForUserRow{
|
||||
Artist: r.Artist,
|
||||
CoverAlbumID: r.CoverAlbumID,
|
||||
AlbumCount: r.AlbumCount,
|
||||
})
|
||||
primary = append(primary, dbq.ListRediscoverArtistsForUserRow(r))
|
||||
if len(primary) >= HomeRediscoverLimit {
|
||||
break
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user