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:
committed by
Steve Yegge
parent
a731f5a48f
commit
40ae598751
@@ -31,12 +31,7 @@ func CheckMultiRepoTypes(repoPath string) DoctorCheck {
|
||||
|
||||
// Discover types from each child repo
|
||||
for _, repoPathStr := range multiRepo.Additional {
|
||||
childTypes, err := discoverChildTypes(repoPathStr)
|
||||
if err != nil {
|
||||
details = append(details, fmt.Sprintf(" %s: unable to read (%v)", repoPathStr, err))
|
||||
continue
|
||||
}
|
||||
|
||||
childTypes := discoverChildTypes(repoPathStr)
|
||||
if len(childTypes) > 0 {
|
||||
details = append(details, fmt.Sprintf(" %s: %s", repoPathStr, strings.Join(childTypes, ", ")))
|
||||
} else {
|
||||
@@ -70,8 +65,9 @@ func CheckMultiRepoTypes(repoPath string) DoctorCheck {
|
||||
}
|
||||
}
|
||||
|
||||
// discoverChildTypes reads custom types from a child repo's config or database
|
||||
func discoverChildTypes(repoPath string) ([]string, error) {
|
||||
// discoverChildTypes reads custom types from a child repo's config or database.
|
||||
// Returns nil if no custom types are found (not an error - child may not have any).
|
||||
func discoverChildTypes(repoPath string) []string {
|
||||
// Expand tilde
|
||||
if strings.HasPrefix(repoPath, "~") {
|
||||
if home, err := os.UserHomeDir(); err == nil {
|
||||
@@ -84,17 +80,17 @@ func discoverChildTypes(repoPath string) ([]string, error) {
|
||||
// First try reading from database config table
|
||||
types, err := readTypesFromDB(beadsDir)
|
||||
if err == nil && len(types) > 0 {
|
||||
return types, nil
|
||||
return types
|
||||
}
|
||||
|
||||
// Fall back to reading from config.yaml
|
||||
types, err = readTypesFromYAML(beadsDir)
|
||||
if err == nil {
|
||||
return types, nil
|
||||
return types
|
||||
}
|
||||
|
||||
// No custom types found (not an error - child may not have any)
|
||||
return nil, nil
|
||||
// No custom types found
|
||||
return nil
|
||||
}
|
||||
|
||||
// readTypesFromDB reads types.custom from the database config table
|
||||
@@ -232,11 +228,9 @@ func findUnknownTypesInHydratedIssues(repoPath string, multiRepo *config.MultiRe
|
||||
|
||||
// Add child types
|
||||
for _, repoPathStr := range multiRepo.Additional {
|
||||
childTypes, err := discoverChildTypes(repoPathStr)
|
||||
if err == nil {
|
||||
for _, t := range childTypes {
|
||||
knownTypes[t] = true
|
||||
}
|
||||
childTypes := discoverChildTypes(repoPathStr)
|
||||
for _, t := range childTypes {
|
||||
knownTypes[t] = true
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,6 @@ import (
|
||||
"encoding/hex"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"strings"
|
||||
|
||||
"github.com/steveyegge/beads/internal/utils"
|
||||
@@ -54,21 +53,16 @@ func shortSocketDir(canonicalPath string) string {
|
||||
hash := sha256.Sum256([]byte(canonicalPath))
|
||||
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")
|
||||
}
|
||||
|
||||
// tmpDir returns the appropriate temp directory for sockets.
|
||||
// On macOS, /tmp is a symlink to /private/tmp, but /tmp is shorter.
|
||||
func tmpDir() string {
|
||||
if runtime.GOOS == "darwin" {
|
||||
// On macOS, prefer /tmp over $TMPDIR which can be long
|
||||
// (/var/folders/xx/xxxxxxxxxxxx/T/)
|
||||
return "/tmp"
|
||||
}
|
||||
// On Linux and other Unix, use /tmp
|
||||
return "/tmp"
|
||||
}
|
||||
// tmpDir returns the temp directory for sockets.
|
||||
// We always use /tmp because:
|
||||
// - On macOS, $TMPDIR is very long (/var/folders/xx/xxxxxxxxxxxx/T/)
|
||||
// - On Linux, /tmp is standard
|
||||
// - We need short paths due to Unix socket length limits
|
||||
const tmpDir = "/tmp"
|
||||
|
||||
// EnsureSocketDir creates the socket directory if it doesn't exist.
|
||||
// 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
|
||||
// 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 {
|
||||
return "", err
|
||||
}
|
||||
@@ -93,7 +87,7 @@ func CleanupSocketDir(socketPath string) error {
|
||||
dir := filepath.Dir(socketPath)
|
||||
|
||||
// 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
|
||||
_ = os.Remove(socketPath)
|
||||
// Remove directory (will fail if not empty, which is fine)
|
||||
|
||||
Reference in New Issue
Block a user