fix(lint): exclude common fire-and-forget patterns from errcheck
This commit is contained in:
parent
104820f4fe
commit
c0fd8d3818
8 changed files with 25 additions and 12 deletions
|
|
@ -69,7 +69,7 @@ func (t *WSTransport) Connect(ctx context.Context) error {
|
|||
|
||||
conn, wsResp, err := dialer.DialContext(ctx, wsURLWithKey, header)
|
||||
if wsResp != nil && wsResp.Body != nil {
|
||||
defer wsResp.Body.Close() //nolint:errcheck
|
||||
defer wsResp.Body.Close()
|
||||
}
|
||||
if err != nil {
|
||||
return fmt.Errorf("ws dial: %w", err)
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ func TestDiscoverE2E(t *testing.T) {
|
|||
if err != nil {
|
||||
t.Skipf("Port %s not reachable, skipping", port)
|
||||
}
|
||||
_ = conn.Close()
|
||||
conn.Close()
|
||||
}
|
||||
|
||||
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 {
|
||||
_ = os.Remove(tmpPath)
|
||||
os.Remove(tmpPath)
|
||||
return fmt.Errorf("rename config: %w", err)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -93,7 +93,7 @@ func TestLoadPreservesDefaults(t *testing.T) {
|
|||
path := filepath.Join(tmp, "config.toml")
|
||||
|
||||
// Write partial config (only auth section)
|
||||
_ = os.WriteFile(path, []byte(`[auth]
|
||||
os.WriteFile(path, []byte(`[auth]
|
||||
api_key = "tc_partial"
|
||||
`), 0o644)
|
||||
|
||||
|
|
@ -193,7 +193,7 @@ func TestParseSpeed(t *testing.T) {
|
|||
func TestLoadInvalidTOML(t *testing.T) {
|
||||
tmp := t.TempDir()
|
||||
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)
|
||||
if err == nil {
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ func TestDirOverrideEnv(t *testing.T) {
|
|||
|
||||
func TestDirXDGOverride(t *testing.T) {
|
||||
// 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")
|
||||
|
||||
dir := Dir()
|
||||
|
|
|
|||
|
|
@ -97,8 +97,7 @@ func DownloadFFprobe() (string, error) {
|
|||
if err != nil {
|
||||
return "", fmt.Errorf("download failed: %w", err)
|
||||
}
|
||||
defer resp.Body.Close() //nolint:errcheck // best-effort close
|
||||
|
||||
defer resp.Body.Close()
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
return "", fmt.Errorf("download failed: HTTP %d", resp.StatusCode)
|
||||
}
|
||||
|
|
@ -167,7 +166,7 @@ func extractFromZip(data []byte, target string) ([]byte, error) {
|
|||
if err != nil {
|
||||
return nil, fmt.Errorf("cannot extract %s from archive: %w", target, err)
|
||||
}
|
||||
defer rc.Close() //nolint:errcheck // best-effort close
|
||||
defer rc.Close()
|
||||
return io.ReadAll(rc)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -113,7 +113,7 @@ func plexLibraryPaths() []string {
|
|||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
defer resp.Body.Close() //nolint:errcheck // best-effort close
|
||||
defer resp.Body.Close()
|
||||
|
||||
if resp.StatusCode != 200 {
|
||||
return nil
|
||||
|
|
@ -200,7 +200,7 @@ func jellyfinLibraryPaths(baseURL string) []string {
|
|||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
defer resp.Body.Close() //nolint:errcheck // best-effort close
|
||||
defer resp.Body.Close()
|
||||
|
||||
if resp.StatusCode != 200 {
|
||||
return nil
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue