style: apply golangci-lint --fix for all remaining issues

Applied automatic fixes using golangci-lint --fix which resolved:
- All remaining wsl_v5 whitespace issues (28 issues)
- All whitespace formatting issues (1 issue)
- Improved code formatting consistency across the entire codebase

All tests passing and functionality preserved.
This commit is contained in:
Tobias Gesellchen
2026-02-01 22:11:12 +01:00
parent f8f80a5121
commit 2768838bad
24 changed files with 399 additions and 12 deletions
+3
View File
@@ -268,6 +268,7 @@ func (sr *SearchStationResponse) GetAllResults() []SearchResult {
allResults = append(allResults, sr.Songs...)
allResults = append(allResults, sr.Artists...)
allResults = append(allResults, sr.Stations...)
return allResults
}
@@ -306,6 +307,7 @@ func (sr *SearchResult) GetDisplayName() string {
if sr.Name != "" {
return sr.Name
}
return "Unknown"
}
@@ -337,5 +339,6 @@ func (sr *SearchResult) GetFullTitle() string {
if sr.Artist != "" {
return sr.Name + " - " + sr.Artist
}
return sr.Name
}
+32
View File
@@ -15,9 +15,11 @@ func TestNavigateRequest_NewNavigateRequest(t *testing.T) {
if req.SourceAccount != "user@example.com" {
t.Errorf("Expected sourceAccount user@example.com, got %s", req.SourceAccount)
}
if req.StartItem != 1 {
t.Errorf("Expected startItem 1, got %d", req.StartItem)
}
if req.NumItems != 50 {
t.Errorf("Expected numItems 50, got %d", req.NumItems)
}
@@ -29,9 +31,11 @@ func TestNavigateRequest_NewNavigateRequestWithMenu(t *testing.T) {
if req.Source != "PANDORA" {
t.Errorf("Expected source PANDORA, got %s", req.Source)
}
if req.Menu != "radioStations" {
t.Errorf("Expected menu radioStations, got %s", req.Menu)
}
if req.Sort != "dateCreated" {
t.Errorf("Expected sort dateCreated, got %s", req.Sort)
}
@@ -99,6 +103,7 @@ func TestNavigateRequest_XMLMarshalWithItem(t *testing.T) {
if !contains(xmlStr, `source="STORED_MUSIC"`) {
t.Error("XML should contain source attribute")
}
if !contains(xmlStr, `<startItem>1</startItem>`) {
t.Error("XML should contain startItem element")
}
@@ -110,6 +115,7 @@ func TestNavigateRequest_XMLMarshalWithItem(t *testing.T) {
if !contains(xmlStr, `<item`) {
t.Error("XML should contain item element")
}
if !contains(xmlStr, `<ContentItem`) {
t.Error("XML should contain ContentItem element")
}
@@ -149,9 +155,11 @@ func TestNavigateResponse_XMLUnmarshal(t *testing.T) {
if response.Source != "STORED_MUSIC" {
t.Errorf("Expected source STORED_MUSIC, got %s", response.Source)
}
if response.TotalItems != 2 {
t.Errorf("Expected totalItems 2, got %d", response.TotalItems)
}
if len(response.Items) != 2 {
t.Errorf("Expected 2 items, got %d", len(response.Items))
}
@@ -161,12 +169,15 @@ func TestNavigateResponse_XMLUnmarshal(t *testing.T) {
if firstItem.Name != "Album Artists" {
t.Errorf("Expected first item name 'Album Artists', got %s", firstItem.Name)
}
if firstItem.Type != "dir" {
t.Errorf("Expected first item type 'dir', got %s", firstItem.Type)
}
if !firstItem.IsPlayable() {
t.Error("Expected first item to be playable")
}
if !firstItem.IsDirectory() {
t.Error("Expected first item to be a directory")
}
@@ -176,6 +187,7 @@ func TestNavigateResponse_XMLUnmarshal(t *testing.T) {
if secondItem.Name != "Test Track" {
t.Errorf("Expected second item name 'Test Track', got %s", secondItem.Name)
}
if secondItem.ArtistName != "Test Artist" {
t.Errorf("Expected artist name 'Test Artist', got %s", secondItem.ArtistName)
}
@@ -218,6 +230,7 @@ func TestNavigateResponse_FilterMethods(t *testing.T) {
if len(directories) != 1 {
t.Errorf("Expected 1 directory, got %d", len(directories))
}
if directories[0].Name != "Directory 1" {
t.Errorf("Expected directory name 'Directory 1', got %s", directories[0].Name)
}
@@ -227,6 +240,7 @@ func TestNavigateResponse_FilterMethods(t *testing.T) {
if len(tracks) != 1 {
t.Errorf("Expected 1 track, got %d", len(tracks))
}
if tracks[0].Name != "Track 1" {
t.Errorf("Expected track name 'Track 1', got %s", tracks[0].Name)
}
@@ -236,6 +250,7 @@ func TestNavigateResponse_FilterMethods(t *testing.T) {
if len(stations) != 1 {
t.Errorf("Expected 1 station, got %d", len(stations))
}
if stations[0].Name != "Station 1" {
t.Errorf("Expected station name 'Station 1', got %s", stations[0].Name)
}
@@ -388,9 +403,11 @@ func TestRemoveStationRequest(t *testing.T) {
if !contains(xmlStr, `source="PANDORA"`) {
t.Error("XML should contain source attribute")
}
if !contains(xmlStr, `location="126740707481236361"`) {
t.Error("XML should contain location attribute")
}
if !contains(xmlStr, `<itemName>Test Station</itemName>`) {
t.Error("XML should contain itemName element")
}
@@ -402,9 +419,11 @@ func TestSearchStationRequest_NewSearchStationRequest(t *testing.T) {
if req.Source != "PANDORA" {
t.Errorf("Expected source PANDORA, got %s", req.Source)
}
if req.SourceAccount != "user123" {
t.Errorf("Expected sourceAccount user123, got %s", req.SourceAccount)
}
if req.SearchTerm != "Zach Williams" {
t.Errorf("Expected searchTerm 'Zach Williams', got %s", req.SearchTerm)
}
@@ -483,15 +502,19 @@ func TestSearchStationResponse_XMLUnmarshal(t *testing.T) {
if response.DeviceID != "1004567890AA" {
t.Errorf("Expected deviceID '1004567890AA', got %s", response.DeviceID)
}
if response.Source != "PANDORA" {
t.Errorf("Expected source PANDORA, got %s", response.Source)
}
if len(response.Songs) != 1 {
t.Errorf("Expected 1 song result, got %d", len(response.Songs))
}
if len(response.Artists) != 1 {
t.Errorf("Expected 1 artist result, got %d", len(response.Artists))
}
if len(response.Stations) != 1 {
t.Errorf("Expected 1 station result, got %d", len(response.Stations))
}
@@ -501,9 +524,11 @@ func TestSearchStationResponse_XMLUnmarshal(t *testing.T) {
if song.Name != "Old Church Choir" {
t.Errorf("Expected song name 'Old Church Choir', got %s", song.Name)
}
if song.Artist != "Zach Williams" {
t.Errorf("Expected artist 'Zach Williams', got %s", song.Artist)
}
if song.Token != "S10657777" {
t.Errorf("Expected token 'S10657777', got %s", song.Token)
}
@@ -513,6 +538,7 @@ func TestSearchStationResponse_XMLUnmarshal(t *testing.T) {
if artist.Name != "Zach Williams" {
t.Errorf("Expected artist name 'Zach Williams', got %s", artist.Name)
}
if !artist.IsArtist() {
t.Error("Expected result to be identified as artist")
}
@@ -522,6 +548,7 @@ func TestSearchStationResponse_XMLUnmarshal(t *testing.T) {
if station.Name != "Classic Rock Station" {
t.Errorf("Expected station name 'Classic Rock Station', got %s", station.Name)
}
if !station.IsStation() {
t.Error("Expected result to be identified as station")
}
@@ -585,6 +612,7 @@ func TestSearchStationResponse_HelperMethods(t *testing.T) {
if !emptyResponse.IsEmpty() {
t.Error("Expected empty response to be empty")
}
if emptyResponse.HasResults() {
t.Error("Expected empty response to have no results")
}
@@ -630,6 +658,7 @@ func TestSearchResult_HelperMethods(t *testing.T) {
if !tt.result.IsSong() {
t.Error("Expected result to be identified as song")
}
if tt.result.IsArtist() || tt.result.IsStation() {
t.Error("Result incorrectly identified as artist or station")
}
@@ -637,6 +666,7 @@ func TestSearchResult_HelperMethods(t *testing.T) {
if !tt.result.IsArtist() {
t.Error("Expected result to be identified as artist")
}
if tt.result.IsSong() || tt.result.IsStation() {
t.Error("Result incorrectly identified as song or station")
}
@@ -644,6 +674,7 @@ func TestSearchResult_HelperMethods(t *testing.T) {
if !tt.result.IsStation() {
t.Error("Expected result to be identified as station")
}
if tt.result.IsSong() || tt.result.IsArtist() {
t.Error("Result incorrectly identified as song or artist")
}
@@ -685,5 +716,6 @@ func containsSubstring(s, substr string) bool {
return true
}
}
return false
}
+9
View File
@@ -75,6 +75,7 @@ func (sa *ServiceAvailability) GetAvailableServices() []Service {
available = append(available, service)
}
}
return available
}
@@ -85,11 +86,13 @@ func (sa *ServiceAvailability) GetUnavailableServices() []Service {
}
var unavailable []Service
for _, service := range sa.Services.Service {
if !service.IsAvailable {
unavailable = append(unavailable, service)
}
}
return unavailable
}
@@ -104,6 +107,7 @@ func (sa *ServiceAvailability) IsServiceAvailable(serviceType ServiceType) bool
return true
}
}
return false
}
@@ -118,6 +122,7 @@ func (sa *ServiceAvailability) GetServiceByType(serviceType ServiceType) *Servic
return &service
}
}
return nil
}
@@ -182,6 +187,7 @@ func (sa *ServiceAvailability) GetStreamingServices() []Service {
}
}
}
return streaming
}
@@ -198,6 +204,7 @@ func (sa *ServiceAvailability) GetLocalServices() []Service {
}
var local []Service
for _, service := range sa.Services.Service {
for _, localType := range localTypes {
if service.Type == string(localType) {
@@ -206,6 +213,7 @@ func (sa *ServiceAvailability) GetLocalServices() []Service {
}
}
}
return local
}
@@ -214,6 +222,7 @@ func (sa *ServiceAvailability) GetServiceCount() int {
if sa.Services == nil {
return 0
}
return len(sa.Services.Service)
}
+59
View File
@@ -33,9 +33,11 @@ func TestServiceAvailability_UnmarshalXML(t *testing.T) {
</serviceAvailability>`,
validate: func(t *testing.T, sa *ServiceAvailability) {
t.Helper()
if sa.Services == nil {
t.Fatal("services should not be nil")
}
if len(sa.Services.Service) != 13 {
t.Errorf("expected 13 services, got %d", len(sa.Services.Service))
}
@@ -45,9 +47,11 @@ func TestServiceAvailability_UnmarshalXML(t *testing.T) {
if spotifyService == nil {
t.Fatal("spotify service should not be nil")
}
if !spotifyService.IsAvailable {
t.Error("spotify service should be available")
}
if spotifyService.Reason != "" {
t.Error("spotify service should not have a reason")
}
@@ -56,9 +60,11 @@ func TestServiceAvailability_UnmarshalXML(t *testing.T) {
if bluetoothService == nil {
t.Fatal("bluetooth service should not be nil")
}
if bluetoothService.IsAvailable {
t.Error("bluetooth service should not be available")
}
if bluetoothService.Reason != "INVALID_SOURCE_TYPE" {
t.Errorf("bluetooth service reason should be 'INVALID_SOURCE_TYPE', got '%s'", bluetoothService.Reason)
}
@@ -73,9 +79,11 @@ func TestServiceAvailability_UnmarshalXML(t *testing.T) {
</serviceAvailability>`,
validate: func(t *testing.T, sa *ServiceAvailability) {
t.Helper()
if sa.Services == nil {
t.Fatal("services should not be nil")
}
if len(sa.Services.Service) != 0 {
t.Errorf("expected 0 services, got %d", len(sa.Services.Service))
}
@@ -90,15 +98,19 @@ func TestServiceAvailability_UnmarshalXML(t *testing.T) {
</serviceAvailability>`,
validate: func(t *testing.T, sa *ServiceAvailability) {
t.Helper()
if sa.Services == nil {
t.Fatal("services should not be nil")
}
if len(sa.Services.Service) != 1 {
t.Errorf("expected 1 service, got %d", len(sa.Services.Service))
}
if sa.Services.Service[0].Type != "SPOTIFY" {
t.Errorf("expected SPOTIFY, got %s", sa.Services.Service[0].Type)
}
if !sa.Services.Service[0].IsAvailable {
t.Error("service should be available")
}
@@ -109,6 +121,7 @@ func TestServiceAvailability_UnmarshalXML(t *testing.T) {
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
var sa ServiceAvailability
err := xml.Unmarshal([]byte(tt.xmlData), &sa)
if err != nil {
t.Fatalf("failed to unmarshal XML: %v", err)
@@ -135,9 +148,11 @@ func TestServiceAvailability_GetAvailableServices(t *testing.T) {
if len(available) != 2 {
t.Errorf("expected 2 available services, got %d", len(available))
}
if available[0].Type != "SPOTIFY" {
t.Errorf("expected first service to be SPOTIFY, got %s", available[0].Type)
}
if available[1].Type != "AIRPLAY" {
t.Errorf("expected second service to be AIRPLAY, got %s", available[1].Type)
}
@@ -159,9 +174,11 @@ func TestServiceAvailability_GetUnavailableServices(t *testing.T) {
if len(unavailable) != 2 {
t.Errorf("expected 2 unavailable services, got %d", len(unavailable))
}
if unavailable[0].Type != "BLUETOOTH" {
t.Errorf("expected first service to be BLUETOOTH, got %s", unavailable[0].Type)
}
if unavailable[1].Type != "ALEXA" {
t.Errorf("expected second service to be ALEXA, got %s", unavailable[1].Type)
}
@@ -180,9 +197,11 @@ func TestServiceAvailability_IsServiceAvailable(t *testing.T) {
if !sa.IsServiceAvailable(ServiceTypeSpotify) {
t.Error("Spotify should be available")
}
if sa.IsServiceAvailable(ServiceTypeBluetooth) {
t.Error("Bluetooth should not be available")
}
if sa.IsServiceAvailable(ServiceTypeAlexa) {
t.Error("Alexa should not be available (not in list)")
}
@@ -202,9 +221,11 @@ func TestServiceAvailability_GetServiceByType(t *testing.T) {
if spotifyService == nil {
t.Fatal("spotify service should not be nil")
}
if spotifyService.Type != "SPOTIFY" {
t.Errorf("expected SPOTIFY, got %s", spotifyService.Type)
}
if !spotifyService.IsAvailable {
t.Error("spotify service should be available")
}
@@ -213,12 +234,15 @@ func TestServiceAvailability_GetServiceByType(t *testing.T) {
if bluetoothService == nil {
t.Fatal("bluetooth service should not be nil")
}
if bluetoothService.Type != "BLUETOOTH" {
t.Errorf("expected BLUETOOTH, got %s", bluetoothService.Type)
}
if bluetoothService.IsAvailable {
t.Error("bluetooth service should not be available")
}
if bluetoothService.Reason != "DEVICE_NOT_FOUND" {
t.Errorf("expected DEVICE_NOT_FOUND, got %s", bluetoothService.Reason)
}
@@ -247,21 +271,27 @@ func TestServiceAvailability_ConvenienceMethods(t *testing.T) {
if !sa.HasSpotify() {
t.Error("should have Spotify")
}
if sa.HasBluetooth() {
t.Error("should not have Bluetooth")
}
if !sa.HasAirPlay() {
t.Error("should have AirPlay")
}
if sa.HasAlexa() {
t.Error("should not have Alexa")
}
if !sa.HasTuneIn() {
t.Error("should have TuneIn")
}
if !sa.HasPandora() {
t.Error("should have Pandora")
}
if !sa.HasLocalMusic() {
t.Error("should have Local Music")
}
@@ -362,9 +392,11 @@ func TestServiceAvailability_CountMethods(t *testing.T) {
if sa.GetServiceCount() != 4 {
t.Errorf("expected 4 total services, got %d", sa.GetServiceCount())
}
if sa.GetAvailableServiceCount() != 2 {
t.Errorf("expected 2 available services, got %d", sa.GetAvailableServiceCount())
}
if sa.GetUnavailableServiceCount() != 2 {
t.Errorf("expected 2 unavailable services, got %d", sa.GetUnavailableServiceCount())
}
@@ -376,33 +408,43 @@ func TestServiceAvailability_NilServicesHandling(t *testing.T) {
if len(sa.GetAvailableServices()) != 0 {
t.Error("available services should be empty")
}
if len(sa.GetUnavailableServices()) != 0 {
t.Error("unavailable services should be empty")
}
if sa.IsServiceAvailable(ServiceTypeSpotify) {
t.Error("Spotify should not be available")
}
if sa.GetServiceByType(ServiceTypeSpotify) != nil {
t.Error("service should be nil")
}
if sa.HasSpotify() {
t.Error("should not have Spotify")
}
if sa.HasBluetooth() {
t.Error("should not have Bluetooth")
}
if len(sa.GetStreamingServices()) != 0 {
t.Error("streaming services should be empty")
}
if len(sa.GetLocalServices()) != 0 {
t.Error("local services should be empty")
}
if sa.GetServiceCount() != 0 {
t.Error("service count should be 0")
}
if sa.GetAvailableServiceCount() != 0 {
t.Error("available service count should be 0")
}
if sa.GetUnavailableServiceCount() != 0 {
t.Error("unavailable service count should be 0")
}
@@ -414,6 +456,7 @@ func TestService_Methods(t *testing.T) {
if !service.IsType(ServiceTypeSpotify) {
t.Error("service should be of type Spotify")
}
if service.IsType(ServiceTypeBluetooth) {
t.Error("service should not be of type Bluetooth")
}
@@ -441,39 +484,51 @@ func TestServiceType_Constants(t *testing.T) {
if ServiceTypeAirPlay != ServiceType("AIRPLAY") {
t.Error("ServiceTypeAirPlay constant mismatch")
}
if ServiceTypeAlexa != ServiceType("ALEXA") {
t.Error("ServiceTypeAlexa constant mismatch")
}
if ServiceTypeAmazon != ServiceType("AMAZON") {
t.Error("ServiceTypeAmazon constant mismatch")
}
if ServiceTypeBluetooth != ServiceType("BLUETOOTH") {
t.Error("ServiceTypeBluetooth constant mismatch")
}
if ServiceTypeBMX != ServiceType("BMX") {
t.Error("ServiceTypeBMX constant mismatch")
}
if ServiceTypeDeezer != ServiceType("DEEZER") {
t.Error("ServiceTypeDeezer constant mismatch")
}
if ServiceTypeIHeart != ServiceType("IHEART") {
t.Error("ServiceTypeIHeart constant mismatch")
}
if ServiceTypeLocalInternetRadio != ServiceType("LOCAL_INTERNET_RADIO") {
t.Error("ServiceTypeLocalInternetRadio constant mismatch")
}
if ServiceTypeLocalMusic != ServiceType("LOCAL_MUSIC") {
t.Error("ServiceTypeLocalMusic constant mismatch")
}
if ServiceTypeNotification != ServiceType("NOTIFICATION") {
t.Error("ServiceTypeNotification constant mismatch")
}
if ServiceTypePandora != ServiceType("PANDORA") {
t.Error("ServiceTypePandora constant mismatch")
}
if ServiceTypeSpotify != ServiceType("SPOTIFY") {
t.Error("ServiceTypeSpotify constant mismatch")
}
if ServiceTypeTuneIn != ServiceType("TUNEIN") {
t.Error("ServiceTypeTuneIn constant mismatch")
}
@@ -496,6 +551,7 @@ func TestServiceAvailability_MarshalXML(t *testing.T) {
// Unmarshal back to verify roundtrip
var unmarshaled ServiceAvailability
err = xml.Unmarshal(data, &unmarshaled)
if err != nil {
t.Fatalf("failed to unmarshal XML: %v", err)
@@ -504,9 +560,11 @@ func TestServiceAvailability_MarshalXML(t *testing.T) {
if sa.GetServiceCount() != unmarshaled.GetServiceCount() {
t.Error("service count mismatch after roundtrip")
}
if sa.HasSpotify() != unmarshaled.HasSpotify() {
t.Error("Spotify availability mismatch after roundtrip")
}
if sa.HasBluetooth() != unmarshaled.HasBluetooth() {
t.Error("Bluetooth availability mismatch after roundtrip")
}
@@ -515,6 +573,7 @@ func TestServiceAvailability_MarshalXML(t *testing.T) {
if bluetoothService == nil {
t.Fatal("bluetooth service should not be nil after roundtrip")
}
if bluetoothService.Reason != "UNAVAILABLE" {
t.Errorf("expected UNAVAILABLE reason, got %s", bluetoothService.Reason)
}
+19
View File
@@ -20,6 +20,7 @@ func (s *SupportedURLsResponse) GetURLs() []string {
for i, url := range s.URLs {
urls[i] = url.Location
}
return urls
}
@@ -30,6 +31,7 @@ func (s *SupportedURLsResponse) HasURL(location string) bool {
return true
}
}
return false
}
@@ -47,11 +49,13 @@ func (s *SupportedURLsResponse) GetCoreURLs() []string {
}
var available []string
for _, endpoint := range coreEndpoints {
if s.HasURL(endpoint) {
available = append(available, endpoint)
}
}
return available
}
@@ -63,11 +67,13 @@ func (s *SupportedURLsResponse) GetStreamingURLs() []string {
}
var available []string
for _, endpoint := range streamingEndpoints {
if s.HasURL(endpoint) {
available = append(available, endpoint)
}
}
return available
}
@@ -81,11 +87,13 @@ func (s *SupportedURLsResponse) GetAdvancedURLs() []string {
}
var available []string
for _, endpoint := range advancedEndpoints {
if s.HasURL(endpoint) {
available = append(available, endpoint)
}
}
return available
}
@@ -97,11 +105,13 @@ func (s *SupportedURLsResponse) GetNetworkURLs() []string {
}
var available []string
for _, endpoint := range networkEndpoints {
if s.HasURL(endpoint) {
available = append(available, endpoint)
}
}
return available
}
@@ -113,6 +123,7 @@ func (s *SupportedURLsResponse) HasCorePlaybackSupport() bool {
return false
}
}
return true
}
@@ -139,11 +150,13 @@ func (s *SupportedURLsResponse) HasStreamingSupport() bool {
// GetUnsupportedURLs returns a list of common URLs that this device doesn't support
func (s *SupportedURLsResponse) GetUnsupportedURLs(checkList []string) []string {
var unsupported []string
for _, endpoint := range checkList {
if !s.HasURL(endpoint) {
unsupported = append(unsupported, endpoint)
}
}
return unsupported
}
@@ -338,6 +351,7 @@ func (s *SupportedURLsResponse) GetFeaturesByCategory() map[string][]EndpointFea
for _, feature := range features {
// Check if device supports this feature (any of its endpoints)
supported := false
for _, endpoint := range feature.Endpoints {
if s.HasURL(endpoint) {
supported = true
@@ -362,6 +376,7 @@ func (s *SupportedURLsResponse) GetSupportedFeatures() []EndpointFeature {
for _, feature := range features {
// Check if device supports this feature (any of its endpoints)
hasSupport := false
for _, endpoint := range feature.Endpoints {
if s.HasURL(endpoint) {
hasSupport = true
@@ -386,6 +401,7 @@ func (s *SupportedURLsResponse) GetUnsupportedFeatures() []EndpointFeature {
for _, feature := range features {
// Check if device supports this feature (any of its endpoints)
hasSupport := false
for _, endpoint := range feature.Endpoints {
if s.HasURL(endpoint) {
hasSupport = true
@@ -413,6 +429,7 @@ func (s *SupportedURLsResponse) GetPartiallyImplementedFeatures() []EndpointFeat
}
supportedCount := 0
for _, endpoint := range feature.Endpoints {
if s.HasURL(endpoint) {
supportedCount++
@@ -441,6 +458,7 @@ func (s *SupportedURLsResponse) GetMissingEssentialFeatures() []EndpointFeature
// Check if device supports this essential feature
hasSupport := false
for _, endpoint := range feature.Endpoints {
if s.HasURL(endpoint) {
hasSupport = true
@@ -471,6 +489,7 @@ func (s *SupportedURLsResponse) GetFeatureCompleteness() (int, int, int) {
// Check if device supports this feature
hasSupport := false
for _, endpoint := range feature.Endpoints {
if s.HasURL(endpoint) {
hasSupport = true