fix(lint): resolve unparam warnings in doctor and rpc packages

- multirepo.go: discoverChildTypes now returns []string instead of
  ([]string, error) since error was always nil
- socket_path.go: tmpDir changed from function to const since it
  always returned "/tmp" regardless of platform

Fixes CI lint failures caused by unparam linter detecting unused
error returns and constant function results.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

Executed-By: beads/crew/dave
Rig: beads
Role: crew
This commit is contained in:
beads/crew/dave
2026-01-10 23:17:28 -08:00
committed by Steve Yegge
parent a731f5a48f
commit 40ae598751
2 changed files with 20 additions and 32 deletions

View File

@@ -31,12 +31,7 @@ func CheckMultiRepoTypes(repoPath string) DoctorCheck {
// Discover types from each child repo // Discover types from each child repo
for _, repoPathStr := range multiRepo.Additional { for _, repoPathStr := range multiRepo.Additional {
childTypes, err := discoverChildTypes(repoPathStr) childTypes := discoverChildTypes(repoPathStr)
if err != nil {
details = append(details, fmt.Sprintf(" %s: unable to read (%v)", repoPathStr, err))
continue
}
if len(childTypes) > 0 { if len(childTypes) > 0 {
details = append(details, fmt.Sprintf(" %s: %s", repoPathStr, strings.Join(childTypes, ", "))) details = append(details, fmt.Sprintf(" %s: %s", repoPathStr, strings.Join(childTypes, ", ")))
} else { } else {
@@ -70,8 +65,9 @@ func CheckMultiRepoTypes(repoPath string) DoctorCheck {
} }
} }
// discoverChildTypes reads custom types from a child repo's config or database // discoverChildTypes reads custom types from a child repo's config or database.
func discoverChildTypes(repoPath string) ([]string, error) { // Returns nil if no custom types are found (not an error - child may not have any).
func discoverChildTypes(repoPath string) []string {
// Expand tilde // Expand tilde
if strings.HasPrefix(repoPath, "~") { if strings.HasPrefix(repoPath, "~") {
if home, err := os.UserHomeDir(); err == nil { if home, err := os.UserHomeDir(); err == nil {
@@ -84,17 +80,17 @@ func discoverChildTypes(repoPath string) ([]string, error) {
// First try reading from database config table // First try reading from database config table
types, err := readTypesFromDB(beadsDir) types, err := readTypesFromDB(beadsDir)
if err == nil && len(types) > 0 { if err == nil && len(types) > 0 {
return types, nil return types
} }
// Fall back to reading from config.yaml // Fall back to reading from config.yaml
types, err = readTypesFromYAML(beadsDir) types, err = readTypesFromYAML(beadsDir)
if err == nil { if err == nil {
return types, nil return types
} }
// No custom types found (not an error - child may not have any) // No custom types found
return nil, nil return nil
} }
// readTypesFromDB reads types.custom from the database config table // readTypesFromDB reads types.custom from the database config table
@@ -232,11 +228,9 @@ func findUnknownTypesInHydratedIssues(repoPath string, multiRepo *config.MultiRe
// Add child types // Add child types
for _, repoPathStr := range multiRepo.Additional { for _, repoPathStr := range multiRepo.Additional {
childTypes, err := discoverChildTypes(repoPathStr) childTypes := discoverChildTypes(repoPathStr)
if err == nil { for _, t := range childTypes {
for _, t := range childTypes { knownTypes[t] = true
knownTypes[t] = true
}
} }
} }

View File

@@ -7,7 +7,6 @@ import (
"encoding/hex" "encoding/hex"
"os" "os"
"path/filepath" "path/filepath"
"runtime"
"strings" "strings"
"github.com/steveyegge/beads/internal/utils" "github.com/steveyegge/beads/internal/utils"
@@ -54,21 +53,16 @@ func shortSocketDir(canonicalPath string) string {
hash := sha256.Sum256([]byte(canonicalPath)) hash := sha256.Sum256([]byte(canonicalPath))
hashStr := hex.EncodeToString(hash[:4]) // 8 hex chars from 4 bytes hashStr := hex.EncodeToString(hash[:4]) // 8 hex chars from 4 bytes
dir := filepath.Join(tmpDir(), "beads-"+hashStr) dir := filepath.Join(tmpDir, "beads-"+hashStr)
return filepath.Join(dir, "bd.sock") return filepath.Join(dir, "bd.sock")
} }
// tmpDir returns the appropriate temp directory for sockets. // tmpDir returns the temp directory for sockets.
// On macOS, /tmp is a symlink to /private/tmp, but /tmp is shorter. // We always use /tmp because:
func tmpDir() string { // - On macOS, $TMPDIR is very long (/var/folders/xx/xxxxxxxxxxxx/T/)
if runtime.GOOS == "darwin" { // - On Linux, /tmp is standard
// On macOS, prefer /tmp over $TMPDIR which can be long // - We need short paths due to Unix socket length limits
// (/var/folders/xx/xxxxxxxxxxxx/T/) const tmpDir = "/tmp"
return "/tmp"
}
// On Linux and other Unix, use /tmp
return "/tmp"
}
// EnsureSocketDir creates the socket directory if it doesn't exist. // EnsureSocketDir creates the socket directory if it doesn't exist.
// Returns the socket path (unchanged) and any error. // Returns the socket path (unchanged) and any error.
@@ -78,7 +72,7 @@ func EnsureSocketDir(socketPath string) (string, error) {
// Only create if it's a /tmp/beads-* directory // Only create if it's a /tmp/beads-* directory
// Don't create .beads directories - those should exist // Don't create .beads directories - those should exist
if strings.HasPrefix(dir, filepath.Join(tmpDir(), "beads-")) { if strings.HasPrefix(dir, filepath.Join(tmpDir, "beads-")) {
if err := os.MkdirAll(dir, 0700); err != nil { if err := os.MkdirAll(dir, 0700); err != nil {
return "", err return "", err
} }
@@ -93,7 +87,7 @@ func CleanupSocketDir(socketPath string) error {
dir := filepath.Dir(socketPath) dir := filepath.Dir(socketPath)
// Only remove if it's a /tmp/beads-* directory we created // Only remove if it's a /tmp/beads-* directory we created
if strings.HasPrefix(dir, filepath.Join(tmpDir(), "beads-")) { if strings.HasPrefix(dir, filepath.Join(tmpDir, "beads-")) {
// Remove socket file first // Remove socket file first
_ = os.Remove(socketPath) _ = os.Remove(socketPath)
// Remove directory (will fail if not empty, which is fine) // Remove directory (will fail if not empty, which is fine)