mirror of
https://github.com/gesellix/Bose-SoundTouch.git
synced 2026-08-19 00:56:16 +00:00
fix: resolve unparam issues by using constants for default ports
- Added defaultSoundTouchPort constant (8090) to client.go - Updated parseBassHostPort and parseHostPort test utility functions to use constant - Removed unnecessary defaultPort parameters that always received 8090 - Fixed function signatures and all call sites in integration tests Progress: Reduced unparam issues from 3 to 1 (only client.go post method remains) Total issues: 23 → 21 (9% improvement) Remaining: - gocyclo: 14 (complexity) - revive: 1 (DiscoveryService naming) - staticcheck: 5 - unparam: 1 (client.post result parameter - kept for future extensibility)
This commit is contained in:
@@ -23,7 +23,7 @@ func TestClient_Bass_Integration(t *testing.T) {
|
||||
}
|
||||
|
||||
// Parse host:port if provided
|
||||
finalHost, finalPort := parseBassHostPort(host, 8090)
|
||||
finalHost, finalPort := parseBassHostPort(host)
|
||||
|
||||
config := &Config{
|
||||
Host: finalHost,
|
||||
@@ -165,7 +165,7 @@ func TestClient_Bass_IncrementDecrement_Integration(t *testing.T) {
|
||||
}
|
||||
|
||||
// Parse host:port if provided
|
||||
finalHost, finalPort := parseBassHostPort(host, 8090)
|
||||
finalHost, finalPort := parseBassHostPort(host)
|
||||
|
||||
config := &Config{
|
||||
Host: finalHost,
|
||||
@@ -296,7 +296,7 @@ func TestClient_Bass_ErrorHandling_Integration(t *testing.T) {
|
||||
}
|
||||
|
||||
// Parse host:port if provided
|
||||
finalHost, finalPort := parseBassHostPort(host, 8090)
|
||||
finalHost, finalPort := parseBassHostPort(host)
|
||||
|
||||
config := &Config{
|
||||
Host: finalHost,
|
||||
@@ -354,7 +354,7 @@ func BenchmarkClient_Bass_Integration(b *testing.B) {
|
||||
}
|
||||
|
||||
// Parse host:port if provided
|
||||
finalHost, finalPort := parseBassHostPort(host, 8090)
|
||||
finalHost, finalPort := parseBassHostPort(host)
|
||||
|
||||
config := &Config{
|
||||
Host: finalHost,
|
||||
@@ -424,9 +424,9 @@ func BenchmarkClient_Bass_Integration(b *testing.B) {
|
||||
|
||||
// parseBassHostPort is a helper function for integration tests
|
||||
// This is a simple version for test use
|
||||
func parseBassHostPort(hostPort string, defaultPort int) (string, int) {
|
||||
func parseBassHostPort(hostPort string) (string, int) {
|
||||
if !containsSubstring(hostPort, ":") {
|
||||
return hostPort, defaultPort
|
||||
return hostPort, defaultSoundTouchPort
|
||||
}
|
||||
|
||||
// Simple parsing - in real use, we'd use net.SplitHostPort
|
||||
@@ -448,7 +448,7 @@ func parseBassHostPort(hostPort string, defaultPort int) (string, int) {
|
||||
|
||||
if len(parts) == 2 {
|
||||
// Try to parse port
|
||||
port := defaultPort
|
||||
port := defaultSoundTouchPort
|
||||
portStr := parts[1]
|
||||
portInt := 0
|
||||
|
||||
@@ -468,5 +468,5 @@ func parseBassHostPort(hostPort string, defaultPort int) (string, int) {
|
||||
return parts[0], port
|
||||
}
|
||||
|
||||
return hostPort, defaultPort
|
||||
return hostPort, defaultSoundTouchPort
|
||||
}
|
||||
|
||||
@@ -12,6 +12,9 @@ import (
|
||||
"github.com/user_account/bose-soundtouch/pkg/models"
|
||||
)
|
||||
|
||||
// defaultSoundTouchPort is the standard port for SoundTouch devices
|
||||
const defaultSoundTouchPort = 8090
|
||||
|
||||
// Client represents a SoundTouch API client
|
||||
type Client struct {
|
||||
baseURL string
|
||||
|
||||
@@ -987,7 +987,7 @@ func TestClient_GetName_ServerError(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestClient_GetCapabilities_ServerError(t *testing.T) {
|
||||
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
|
||||
w.WriteHeader(http.StatusInternalServerError)
|
||||
_, _ = w.Write([]byte("Internal Server Error"))
|
||||
}))
|
||||
@@ -1015,7 +1015,7 @@ func TestClient_GetCapabilities_ServerError(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestClient_GetPresets_ServerError(t *testing.T) {
|
||||
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
|
||||
w.WriteHeader(http.StatusInternalServerError)
|
||||
_, _ = w.Write([]byte("Internal Server Error"))
|
||||
}))
|
||||
|
||||
@@ -21,7 +21,7 @@ func TestClient_SelectSource_Integration(t *testing.T) {
|
||||
}
|
||||
|
||||
// Parse host:port if provided
|
||||
finalHost, finalPort := parseHostPort(host, 8090)
|
||||
finalHost, finalPort := parseHostPort(host)
|
||||
|
||||
config := &Config{
|
||||
Host: finalHost,
|
||||
@@ -142,7 +142,7 @@ func TestClient_SelectSourceFromItem_Integration(t *testing.T) {
|
||||
}
|
||||
|
||||
// Parse host:port if provided
|
||||
finalHost, finalPort := parseHostPort(host, 8090)
|
||||
finalHost, finalPort := parseHostPort(host)
|
||||
|
||||
config := &Config{
|
||||
Host: finalHost,
|
||||
@@ -190,7 +190,7 @@ func TestClient_SelectSource_ErrorHandling_Integration(t *testing.T) {
|
||||
}
|
||||
|
||||
// Parse host:port if provided
|
||||
finalHost, finalPort := parseHostPort(host, 8090)
|
||||
finalHost, finalPort := parseHostPort(host)
|
||||
|
||||
config := &Config{
|
||||
Host: finalHost,
|
||||
@@ -247,7 +247,7 @@ func TestClient_ConvenienceSourceMethods_Integration(t *testing.T) {
|
||||
}
|
||||
|
||||
// Parse host:port if provided
|
||||
finalHost, finalPort := parseHostPort(host, 8090)
|
||||
finalHost, finalPort := parseHostPort(host)
|
||||
|
||||
config := &Config{
|
||||
Host: finalHost,
|
||||
@@ -347,7 +347,7 @@ func BenchmarkClient_SelectSource_Integration(b *testing.B) {
|
||||
}
|
||||
|
||||
// Parse host:port if provided
|
||||
finalHost, finalPort := parseHostPort(host, 8090)
|
||||
finalHost, finalPort := parseHostPort(host)
|
||||
|
||||
config := &Config{
|
||||
Host: finalHost,
|
||||
@@ -384,9 +384,9 @@ func BenchmarkClient_SelectSource_Integration(b *testing.B) {
|
||||
|
||||
// parseHostPort is a helper function for integration tests
|
||||
// This is a simple version for test use
|
||||
func parseHostPort(hostPort string, defaultPort int) (string, int) {
|
||||
func parseHostPort(hostPort string) (string, int) {
|
||||
if !containsSubstring(hostPort, ":") {
|
||||
return hostPort, defaultPort
|
||||
return hostPort, defaultSoundTouchPort
|
||||
}
|
||||
|
||||
// Simple parsing - in real use, we'd use net.SplitHostPort
|
||||
@@ -408,7 +408,7 @@ func parseHostPort(hostPort string, defaultPort int) (string, int) {
|
||||
|
||||
if len(parts) == 2 {
|
||||
// Try to parse port
|
||||
port := defaultPort
|
||||
port := defaultSoundTouchPort
|
||||
portStr := parts[1]
|
||||
portInt := 0
|
||||
|
||||
@@ -428,5 +428,5 @@ func parseHostPort(hostPort string, defaultPort int) (string, int) {
|
||||
return parts[0], port
|
||||
}
|
||||
|
||||
return hostPort, defaultPort
|
||||
return hostPort, defaultSoundTouchPort
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user