fix(lint): resolve errcheck and bodyclose warnings for golangci-lint v2
This commit is contained in:
parent
64d31bf4ed
commit
104820f4fe
7 changed files with 13 additions and 10 deletions
|
|
@ -67,7 +67,10 @@ func (t *WSTransport) Connect(ctx context.Context) error {
|
||||||
wsURLWithKey += sep + "key=" + t.apiKey
|
wsURLWithKey += sep + "key=" + t.apiKey
|
||||||
}
|
}
|
||||||
|
|
||||||
conn, _, err := dialer.DialContext(ctx, wsURLWithKey, header)
|
conn, wsResp, err := dialer.DialContext(ctx, wsURLWithKey, header)
|
||||||
|
if wsResp != nil && wsResp.Body != nil {
|
||||||
|
defer wsResp.Body.Close() //nolint:errcheck
|
||||||
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("ws dial: %w", err)
|
return fmt.Errorf("ws dial: %w", err)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ func TestDiscoverE2E(t *testing.T) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Skipf("Port %s not reachable, skipping", port)
|
t.Skipf("Port %s not reachable, skipping", port)
|
||||||
}
|
}
|
||||||
conn.Close()
|
_ = conn.Close()
|
||||||
}
|
}
|
||||||
|
|
||||||
t.Run("Discover", func(t *testing.T) {
|
t.Run("Discover", func(t *testing.T) {
|
||||||
|
|
|
||||||
|
|
@ -171,7 +171,7 @@ func Save(cfg Config, path string) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := os.Rename(tmpPath, path); err != nil {
|
if err := os.Rename(tmpPath, path); err != nil {
|
||||||
os.Remove(tmpPath)
|
_ = os.Remove(tmpPath)
|
||||||
return fmt.Errorf("rename config: %w", err)
|
return fmt.Errorf("rename config: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -93,7 +93,7 @@ func TestLoadPreservesDefaults(t *testing.T) {
|
||||||
path := filepath.Join(tmp, "config.toml")
|
path := filepath.Join(tmp, "config.toml")
|
||||||
|
|
||||||
// Write partial config (only auth section)
|
// Write partial config (only auth section)
|
||||||
os.WriteFile(path, []byte(`[auth]
|
_ = os.WriteFile(path, []byte(`[auth]
|
||||||
api_key = "tc_partial"
|
api_key = "tc_partial"
|
||||||
`), 0o644)
|
`), 0o644)
|
||||||
|
|
||||||
|
|
@ -193,7 +193,7 @@ func TestParseSpeed(t *testing.T) {
|
||||||
func TestLoadInvalidTOML(t *testing.T) {
|
func TestLoadInvalidTOML(t *testing.T) {
|
||||||
tmp := t.TempDir()
|
tmp := t.TempDir()
|
||||||
path := filepath.Join(tmp, "config.toml")
|
path := filepath.Join(tmp, "config.toml")
|
||||||
os.WriteFile(path, []byte(`not valid toml [[[`), 0o644)
|
_ = os.WriteFile(path, []byte(`not valid toml [[[`), 0o644)
|
||||||
|
|
||||||
_, err := Load(path)
|
_, err := Load(path)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,7 @@ func TestDirOverrideEnv(t *testing.T) {
|
||||||
|
|
||||||
func TestDirXDGOverride(t *testing.T) {
|
func TestDirXDGOverride(t *testing.T) {
|
||||||
// Clear the custom env so XDG takes effect
|
// Clear the custom env so XDG takes effect
|
||||||
os.Unsetenv("UNARR_CONFIG_DIR")
|
_ = os.Unsetenv("UNARR_CONFIG_DIR")
|
||||||
t.Setenv("XDG_CONFIG_HOME", "/xdg/config")
|
t.Setenv("XDG_CONFIG_HOME", "/xdg/config")
|
||||||
|
|
||||||
dir := Dir()
|
dir := Dir()
|
||||||
|
|
|
||||||
|
|
@ -97,7 +97,7 @@ func DownloadFFprobe() (string, error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", fmt.Errorf("download failed: %w", err)
|
return "", fmt.Errorf("download failed: %w", err)
|
||||||
}
|
}
|
||||||
defer resp.Body.Close()
|
defer resp.Body.Close() //nolint:errcheck // best-effort close
|
||||||
|
|
||||||
if resp.StatusCode != http.StatusOK {
|
if resp.StatusCode != http.StatusOK {
|
||||||
return "", fmt.Errorf("download failed: HTTP %d", resp.StatusCode)
|
return "", fmt.Errorf("download failed: HTTP %d", resp.StatusCode)
|
||||||
|
|
@ -167,7 +167,7 @@ func extractFromZip(data []byte, target string) ([]byte, error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("cannot extract %s from archive: %w", target, err)
|
return nil, fmt.Errorf("cannot extract %s from archive: %w", target, err)
|
||||||
}
|
}
|
||||||
defer rc.Close()
|
defer rc.Close() //nolint:errcheck // best-effort close
|
||||||
return io.ReadAll(rc)
|
return io.ReadAll(rc)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -113,7 +113,7 @@ func plexLibraryPaths() []string {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
defer resp.Body.Close()
|
defer resp.Body.Close() //nolint:errcheck // best-effort close
|
||||||
|
|
||||||
if resp.StatusCode != 200 {
|
if resp.StatusCode != 200 {
|
||||||
return nil
|
return nil
|
||||||
|
|
@ -200,7 +200,7 @@ func jellyfinLibraryPaths(baseURL string) []string {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
defer resp.Body.Close()
|
defer resp.Body.Close() //nolint:errcheck // best-effort close
|
||||||
|
|
||||||
if resp.StatusCode != 200 {
|
if resp.StatusCode != 200 {
|
||||||
return nil
|
return nil
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue