From a74dc96e50e9f7af5fa6730ffde989f2841e5170 Mon Sep 17 00:00:00 2001 From: Tobias Gesellchen Date: Sun, 1 Feb 2026 21:56:13 +0100 Subject: [PATCH] style: fix whitespace and wsl_v5 linting issues - Remove unnecessary trailing/leading whitespace - Add missing whitespace above return statements, if statements, and loops - Fix whitespace around variable declarations and assignments - Improve code readability by following Go whitespace conventions - Maintain functionality while improving code style consistency Addresses majority of wsl_v5 and whitespace linting rules. --- cmd/soundtouch-cli/cmd_info.go | 19 ++++++++++++++++--- cmd/soundtouch-cli/cmd_playback_test.go | 1 - cmd/soundtouch-cli/cmd_station.go | 2 ++ cmd/soundtouch-cli/common_test.go | 2 ++ cmd/soundtouch-cli/serviceavailability.go | 1 - cmd/websocket-demo/main.go | 4 ++++ examples/service-availability/main.go | 7 +++++++ pkg/client/example_test.go | 1 - pkg/client/navigation_integration_test.go | 7 +++++++ pkg/client/navigation_test.go | 4 ---- pkg/models/serviceavailability_test.go | 2 ++ 11 files changed, 40 insertions(+), 10 deletions(-) diff --git a/cmd/soundtouch-cli/cmd_info.go b/cmd/soundtouch-cli/cmd_info.go index dd334ea..86684fd 100644 --- a/cmd/soundtouch-cli/cmd_info.go +++ b/cmd/soundtouch-cli/cmd_info.go @@ -226,6 +226,7 @@ func getSupportedURLs(c *cli.Context) error { } printSupportedURLs(supportedURLs, c) + return nil } @@ -310,6 +311,7 @@ func printFeatureStatus(feature models.EndpointFeature, supportedURLs *models.Su } fmt.Printf(" %s %s", status, feature.Name) + if feature.Essential { fmt.Printf(" ⭐") } @@ -322,11 +324,13 @@ func printFeatureStatus(feature models.EndpointFeature, supportedURLs *models.Su func countSupportedEndpoints(feature models.EndpointFeature, supportedURLs *models.SupportedURLsResponse) int { supportedEndpoints := 0 + for _, endpoint := range feature.Endpoints { if supportedURLs.HasURL(endpoint) { supportedEndpoints++ } } + return supportedEndpoints } @@ -334,6 +338,7 @@ func printVerboseFeatureDetails(feature models.EndpointFeature, supportedEndpoin fmt.Printf(" %s\n", feature.Description) fmt.Printf(" CLI: %s\n", feature.CLICommand) fmt.Printf(" Endpoints: %d/%d supported", supportedEndpoints, len(feature.Endpoints)) + if supportedEndpoints < len(feature.Endpoints) { fmt.Printf(" (partial)") } @@ -377,7 +382,8 @@ func printDetailedEndpoints(supportedURLs *models.SupportedURLsResponse) { // Show core functionality coreURLs := supportedURLs.GetCoreURLs() if len(coreURLs) > 0 { - fmt.Printf("⚔ Core Functionality (%d endpoints):\n", len(coreURLs)) + fmt.Printf("šŸŽ® Core Functionality (%d endpoints):\n", len(coreURLs)) + for _, url := range coreURLs { fmt.Printf(" • %s\n", url) } @@ -410,6 +416,7 @@ func printDetailedEndpoints(supportedURLs *models.SupportedURLsResponse) { networkURLs := supportedURLs.GetNetworkURLs() if len(networkURLs) > 0 { fmt.Printf("🌐 Network & Connectivity (%d endpoints):\n", len(networkURLs)) + for _, url := range networkURLs { fmt.Printf(" • %s\n", url) } @@ -487,7 +494,8 @@ func printDeviceAnalysis(supportedURLs *models.SupportedURLsResponse) { // Show what's missing unsupportedFeatures := supportedURLs.GetUnsupportedFeatures() if len(unsupportedFeatures) > 0 { - fmt.Printf("āŒ Unavailable Features (%d):\n", len(unsupportedFeatures)) + fmt.Printf("āŒ Unsupported Features (%d):\n", len(unsupportedFeatures)) + for _, feature := range unsupportedFeatures { fmt.Printf(" • %s - %s\n", feature.Name, feature.Description) } @@ -497,9 +505,11 @@ func printDeviceAnalysis(supportedURLs *models.SupportedURLsResponse) { // Partial implementations partial := supportedURLs.GetPartiallyImplementedFeatures() if len(partial) > 0 { - fmt.Printf("āš ļø Partially Supported Features (%d):\n", len(partial)) + fmt.Printf("āš ļø Partially Supported Features (%d):\n", len(partial)) + for _, feature := range partial { supportedCount := 0 + for _, endpoint := range feature.Endpoints { if supportedURLs.HasURL(endpoint) { supportedCount++ @@ -522,6 +532,7 @@ func classifyDevice(supportedURLs *models.SupportedURLsResponse) string { if supportedURLs.HasMultiroomSupport() && supportedURLs.HasAdvancedAudioSupport() { return "Premium SoundTouch Speaker (Full Feature Set)" } + if supportedURLs.HasMultiroomSupport() { return "Standard SoundTouch Speaker (Multiroom Capable)" } @@ -529,6 +540,7 @@ func classifyDevice(supportedURLs *models.SupportedURLsResponse) string { if supportedURLs.HasStreamingSupport() && supportedURLs.HasPresetSupport() { return "Basic SoundTouch Speaker" } + if supportedURLs.HasCorePlaybackSupport() { return "Essential SoundTouch Device" } @@ -622,6 +634,7 @@ func getCategoryEmoji(category string) string { if emoji, exists := emojis[category]; exists { return emoji } + return "šŸ“‹" } diff --git a/cmd/soundtouch-cli/cmd_playback_test.go b/cmd/soundtouch-cli/cmd_playback_test.go index 5688531..c7ba5b2 100644 --- a/cmd/soundtouch-cli/cmd_playback_test.go +++ b/cmd/soundtouch-cli/cmd_playback_test.go @@ -221,7 +221,6 @@ func shouldShowContentDetails(verbose bool, contentItem *models.ContentItem) boo // This mirrors the exact logic from cmd_playback.go: // showDetails := verbose || (nowPlaying.ContentItem != nil && nowPlaying.ContentItem.Location != "") // if showDetails && nowPlaying.ContentItem != nil { ... } - hasLocationData := contentItem != nil && contentItem.Location != "" showDetails := verbose || hasLocationData diff --git a/cmd/soundtouch-cli/cmd_station.go b/cmd/soundtouch-cli/cmd_station.go index 33cea7a..21ba80b 100644 --- a/cmd/soundtouch-cli/cmd_station.go +++ b/cmd/soundtouch-cli/cmd_station.go @@ -30,6 +30,7 @@ func searchStations(c *cli.Context) error { // Check service availability for the source checker := NewServiceAvailabilityChecker(client) + actionDescription := fmt.Sprintf("search %s stations", source) if !checker.CheckSourceAvailable(source, actionDescription) { return fmt.Errorf("source '%s' is not available for station search", source) @@ -192,6 +193,7 @@ func addStation(c *cli.Context) error { // Check service availability for the source checker := NewServiceAvailabilityChecker(client) + actionDescription := fmt.Sprintf("add %s station", source) if !checker.CheckSourceAvailable(source, actionDescription) { return fmt.Errorf("source '%s' is not available for adding stations", source) diff --git a/cmd/soundtouch-cli/common_test.go b/cmd/soundtouch-cli/common_test.go index beeca88..5a5b807 100644 --- a/cmd/soundtouch-cli/common_test.go +++ b/cmd/soundtouch-cli/common_test.go @@ -18,6 +18,7 @@ func TestFetchTuneInMetadata(t *testing.T) { ` + w.WriteHeader(http.StatusOK) w.Write([]byte(html)) })) @@ -26,6 +27,7 @@ func TestFetchTuneInMetadata(t *testing.T) { // Temporarily override httpClient to use test server oldClient := httpClient httpClient = ts.Client() + defer func() { httpClient = oldClient }() metadata, err := fetchTuneInMetadata("https://tunein.com/radio/WDR-2-Rheinland-1004-s213886/") diff --git a/cmd/soundtouch-cli/serviceavailability.go b/cmd/soundtouch-cli/serviceavailability.go index 96660a8..6eaaffe 100644 --- a/cmd/soundtouch-cli/serviceavailability.go +++ b/cmd/soundtouch-cli/serviceavailability.go @@ -58,7 +58,6 @@ func (sac *ServiceAvailabilityChecker) loadServiceAvailability() { sac.serviceAvailability = serviceAvailability sac.cached = true - } // CheckServiceAvailable validates if a service is available and provides user feedback diff --git a/cmd/websocket-demo/main.go b/cmd/websocket-demo/main.go index 26fe14d..4ddd32e 100644 --- a/cmd/websocket-demo/main.go +++ b/cmd/websocket-demo/main.go @@ -343,19 +343,23 @@ func handleConnection(event *models.ConnectionStateUpdatedEvent) { func handlePreset(event *models.PresetUpdatedEvent, verbose bool) { presets := &event.Presets + deviceHeader := "\nšŸ“» Presets Update" if event.DeviceID != "" { deviceHeader += fmt.Sprintf(" [%s]", event.DeviceID) } + fmt.Printf("%s:\n", deviceHeader) fmt.Printf(" šŸ“» Total presets: %d\n", len(presets.Preset)) for _, preset := range presets.Preset { fmt.Printf(" šŸ“» Preset %d:", preset.ID) + if preset.ContentItem != nil { fmt.Printf(" %s", preset.ContentItem.ItemName) fmt.Printf(" (%s)", preset.ContentItem.Source) } + fmt.Println() } diff --git a/examples/service-availability/main.go b/examples/service-availability/main.go index d5563ad..0128d5a 100644 --- a/examples/service-availability/main.go +++ b/examples/service-availability/main.go @@ -67,6 +67,7 @@ func displayServiceReport(sa *models.ServiceAvailability) { // Available services fmt.Println("\nšŸ“± AVAILABLE SERVICES:") + availableServices := sa.GetAvailableServices() if len(availableServices) == 0 { fmt.Println(" None") @@ -78,6 +79,7 @@ func displayServiceReport(sa *models.ServiceAvailability) { // Unavailable services fmt.Println("\nāŒ UNAVAILABLE SERVICES:") + unavailableServices := sa.GetUnavailableServices() if len(unavailableServices) == 0 { fmt.Println(" None") @@ -102,6 +104,7 @@ func displayServiceCategories(sa *models.ServiceAvailability) { fmt.Println("\nšŸŽµ STREAMING SERVICES:") streamingServices := sa.GetStreamingServices() availableCount := 0 + for _, service := range streamingServices { status := "āŒ" if service.IsAvailable { @@ -115,6 +118,7 @@ func displayServiceCategories(sa *models.ServiceAvailability) { fmt.Println("\nšŸ”— LOCAL INPUT SERVICES:") localServices := sa.GetLocalServices() localAvailableCount := 0 + for _, service := range localServices { status := "āŒ" if service.IsAvailable { @@ -123,6 +127,7 @@ func displayServiceCategories(sa *models.ServiceAvailability) { } fmt.Printf(" %s %s\n", status, formatServiceName(service.Type)) } + fmt.Printf(" Summary: %d/%d local services available\n", localAvailableCount, len(localServices)) } @@ -215,6 +220,7 @@ func getTroubleshootingTip(serviceType, reason string) string { if reason == "INVALID_SOURCE_TYPE" { return "This device may not support Bluetooth audio input" } + return "Check if Bluetooth is enabled and try restarting the device" case "SPOTIFY": return "Ensure you have a Spotify Premium account and are logged in" @@ -226,6 +232,7 @@ func getTroubleshootingTip(serviceType, reason string) string { if reason != "" { return fmt.Sprintf("Reason: %s", reason) } + return "Service is currently unavailable" } } diff --git a/pkg/client/example_test.go b/pkg/client/example_test.go index f841aba..9b5ef6f 100644 --- a/pkg/client/example_test.go +++ b/pkg/client/example_test.go @@ -288,7 +288,6 @@ func ExampleClient_GetCapabilities() { func ExampleClient_GetSupportedURLs_concept() { // Example of how to use GetSupportedURLs() method // Note: This example shows the concept but doesn't execute to avoid requiring a real device - config := &client.Config{Host: "192.168.1.100"} c := client.NewClient(config) diff --git a/pkg/client/navigation_integration_test.go b/pkg/client/navigation_integration_test.go index 9b25bcd..86e3bd8 100644 --- a/pkg/client/navigation_integration_test.go +++ b/pkg/client/navigation_integration_test.go @@ -21,6 +21,7 @@ func TestClient_Navigation_Integration(t *testing.T) { // Parse host:port if provided var finalHost string + var finalPort int if strings.Contains(host, ":") { parts := strings.Split(host, ":") @@ -153,6 +154,7 @@ func TestClient_StationManagement_Integration(t *testing.T) { // Parse host:port if provided var finalHost string + var finalPort int if strings.Contains(host, ":") { parts := strings.Split(host, ":") @@ -185,6 +187,7 @@ func TestClient_StationManagement_Integration(t *testing.T) { for _, source := range sources.SourceItem { if source.Source == "PANDORA" && source.Status.IsReady() { pandoraAccount = source.SourceAccount + break } } @@ -207,6 +210,7 @@ func TestClient_StationManagement_Integration(t *testing.T) { // Try to find an artist or station result to add var tokenToAdd string + var nameToAdd string artists := searchResponse.GetArtists() @@ -241,13 +245,16 @@ func TestClient_StationManagement_Integration(t *testing.T) { } var testSource string + var testAccount string // Look for STORED_MUSIC as it typically has containers + for _, source := range sources.SourceItem { if source.Source == "STORED_MUSIC" && source.Status.IsReady() { testSource = source.Source testAccount = source.SourceAccount + break } } diff --git a/pkg/client/navigation_test.go b/pkg/client/navigation_test.go index eb1965d..ba93ce6 100644 --- a/pkg/client/navigation_test.go +++ b/pkg/client/navigation_test.go @@ -254,7 +254,6 @@ func TestClient_NavigateContainer(t *testing.T) { } client := NewClient(config) client.baseURL = server.URL - response, err := client.NavigateContainer("STORED_MUSIC", "device123/0", 1, 1000, containerItem) if err != nil { @@ -546,7 +545,6 @@ func TestClient_GetPandoraStations(t *testing.T) { } client := NewClient(config) client.baseURL = server.URL - response, err := client.GetPandoraStations("user123") if err != nil { @@ -835,7 +833,6 @@ func TestClient_SearchPandoraStations(t *testing.T) { } client := NewClient(config) client.baseURL = server.URL - response, err := client.SearchPandoraStations("user123", "Taylor Swift") if err != nil { @@ -922,7 +919,6 @@ func TestClient_SearchSpotifyContent(t *testing.T) { } client := NewClient(config) client.baseURL = server.URL - response, err := client.SearchSpotifyContent("user@example.com", "Queen") if err != nil { diff --git a/pkg/models/serviceavailability_test.go b/pkg/models/serviceavailability_test.go index 71ca51e..95d8f8e 100644 --- a/pkg/models/serviceavailability_test.go +++ b/pkg/models/serviceavailability_test.go @@ -536,6 +536,7 @@ func BenchmarkServiceAvailability_GetAvailableServices(b *testing.B) { } b.ResetTimer() + for i := 0; i < b.N; i++ { _ = sa.GetAvailableServices() } @@ -555,6 +556,7 @@ func BenchmarkServiceAvailability_IsServiceAvailable(b *testing.B) { } b.ResetTimer() + for i := 0; i < b.N; i++ { _ = sa.IsServiceAvailable(ServiceTypeSpotify) }