Fix revive style issues (bd-56)
- Fix 14 unused-parameter warnings (rename to _) - Fix 2 redefines-builtin-id (max→maxCount, min→minInt) - Fix 3 indent-error-flow issues with gofmt - Merged duplicate bd-126 into bd-116
This commit is contained in:
+2
-2
File diff suppressed because one or more lines are too long
@@ -177,7 +177,7 @@ func TestLibraryIntegration(t *testing.T) {
|
|||||||
})
|
})
|
||||||
|
|
||||||
// Test 2: Get issue
|
// Test 2: Get issue
|
||||||
t.Run("GetIssue", func(t *testing.T) {
|
t.Run("GetIssue", func(_ *testing.T) {
|
||||||
issue := h.createIssue("Get test", beads.TypeBug, 1)
|
issue := h.createIssue("Get test", beads.TypeBug, 1)
|
||||||
retrieved := h.getIssue(issue.ID)
|
retrieved := h.getIssue(issue.ID)
|
||||||
h.assertEqual(issue.Title, retrieved.Title, "title")
|
h.assertEqual(issue.Title, retrieved.Title, "title")
|
||||||
@@ -185,7 +185,7 @@ func TestLibraryIntegration(t *testing.T) {
|
|||||||
})
|
})
|
||||||
|
|
||||||
// Test 3: Update issue
|
// Test 3: Update issue
|
||||||
t.Run("UpdateIssue", func(t *testing.T) {
|
t.Run("UpdateIssue", func(_ *testing.T) {
|
||||||
issue := h.createIssue("Update test", beads.TypeTask, 2)
|
issue := h.createIssue("Update test", beads.TypeTask, 2)
|
||||||
updates := map[string]interface{}{"status": beads.StatusInProgress, "assignee": "test-user"}
|
updates := map[string]interface{}{"status": beads.StatusInProgress, "assignee": "test-user"}
|
||||||
h.updateIssue(issue.ID, updates)
|
h.updateIssue(issue.ID, updates)
|
||||||
@@ -195,7 +195,7 @@ func TestLibraryIntegration(t *testing.T) {
|
|||||||
})
|
})
|
||||||
|
|
||||||
// Test 4: Add dependency
|
// Test 4: Add dependency
|
||||||
t.Run("AddDependency", func(t *testing.T) {
|
t.Run("AddDependency", func(_ *testing.T) {
|
||||||
issue1 := h.createIssue("Parent task", beads.TypeTask, 1)
|
issue1 := h.createIssue("Parent task", beads.TypeTask, 1)
|
||||||
issue2 := h.createIssue("Child task", beads.TypeTask, 1)
|
issue2 := h.createIssue("Child task", beads.TypeTask, 1)
|
||||||
h.addDependency(issue1.ID, issue2.ID)
|
h.addDependency(issue1.ID, issue2.ID)
|
||||||
|
|||||||
+2
-2
@@ -42,7 +42,7 @@ Examples:
|
|||||||
bd compact --id bd-42 --force # Force compact (bypass checks)
|
bd compact --id bd-42 --force # Force compact (bypass checks)
|
||||||
bd compact --stats # Show statistics
|
bd compact --stats # Show statistics
|
||||||
`,
|
`,
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(_ *cobra.Command, _ []string) {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
|
|
||||||
// Handle compact stats first
|
// Handle compact stats first
|
||||||
@@ -404,7 +404,7 @@ func progressBar(current, total int) string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//nolint:unparam // ctx may be used in future for cancellation
|
//nolint:unparam // ctx may be used in future for cancellation
|
||||||
func runCompactRPC(ctx context.Context) {
|
func runCompactRPC(_ context.Context) {
|
||||||
if compactID != "" && compactAll {
|
if compactID != "" && compactAll {
|
||||||
fmt.Fprintf(os.Stderr, "Error: cannot use --id and --all together\n")
|
fmt.Fprintf(os.Stderr, "Error: cannot use --id and --all together\n")
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
|
|||||||
+1
-1
@@ -34,7 +34,7 @@ var configSetCmd = &cobra.Command{
|
|||||||
Use: "set <key> <value>",
|
Use: "set <key> <value>",
|
||||||
Short: "Set a configuration value",
|
Short: "Set a configuration value",
|
||||||
Args: cobra.ExactArgs(2),
|
Args: cobra.ExactArgs(2),
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(_ *cobra.Command, args []string) {
|
||||||
// Config operations work in direct mode only
|
// Config operations work in direct mode only
|
||||||
if err := ensureDirectMode("config set requires direct database access"); err != nil {
|
if err := ensureDirectMode("config set requires direct database access"); err != nil {
|
||||||
fmt.Fprintf(os.Stderr, "Error: %v\n", err)
|
fmt.Fprintf(os.Stderr, "Error: %v\n", err)
|
||||||
|
|||||||
+4
-3
@@ -564,10 +564,12 @@ func migrateToGlobalDaemon() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func stopDaemon(pidFile string) {
|
func stopDaemon(pidFile string) {
|
||||||
if isRunning, pid := isDaemonRunning(pidFile); !isRunning {
|
isRunning, pid := isDaemonRunning(pidFile)
|
||||||
|
if !isRunning {
|
||||||
fmt.Println("Daemon is not running")
|
fmt.Println("Daemon is not running")
|
||||||
return
|
return
|
||||||
} else {
|
}
|
||||||
|
|
||||||
fmt.Printf("Stopping daemon (PID %d)...\n", pid)
|
fmt.Printf("Stopping daemon (PID %d)...\n", pid)
|
||||||
|
|
||||||
process, err := os.FindProcess(pid)
|
process, err := os.FindProcess(pid)
|
||||||
@@ -605,7 +607,6 @@ func stopDaemon(pidFile string) {
|
|||||||
_ = os.Remove(pidFile)
|
_ = os.Remove(pidFile)
|
||||||
fmt.Println("Daemon killed")
|
fmt.Println("Daemon killed")
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
func startDaemon(interval time.Duration, autoCommit, autoPush bool, logFile, pidFile string, global bool) {
|
func startDaemon(interval time.Duration, autoCommit, autoPush bool, logFile, pidFile string, global bool) {
|
||||||
logPath, err := getLogFilePath(logFile, global)
|
logPath, err := getLogFilePath(logFile, global)
|
||||||
|
|||||||
+1
-1
@@ -375,7 +375,7 @@ func removeIssueFromJSONL(issueID string) error {
|
|||||||
|
|
||||||
// deleteBatch handles deletion of multiple issues
|
// deleteBatch handles deletion of multiple issues
|
||||||
//nolint:unparam // cmd parameter required for potential future use
|
//nolint:unparam // cmd parameter required for potential future use
|
||||||
func deleteBatch(cmd *cobra.Command, issueIDs []string, force bool, dryRun bool, cascade bool) {
|
func deleteBatch(_ *cobra.Command, issueIDs []string, force bool, dryRun bool, cascade bool) {
|
||||||
// Ensure we have a direct store when daemon lacks delete support
|
// Ensure we have a direct store when daemon lacks delete support
|
||||||
if daemonClient != nil {
|
if daemonClient != nil {
|
||||||
if err := ensureDirectMode("daemon does not support delete command"); err != nil {
|
if err := ensureDirectMode("daemon does not support delete command"); err != nil {
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ Example:
|
|||||||
bd duplicates # Show all duplicate groups
|
bd duplicates # Show all duplicate groups
|
||||||
bd duplicates --auto-merge # Automatically merge all duplicates
|
bd duplicates --auto-merge # Automatically merge all duplicates
|
||||||
bd duplicates --dry-run # Show what would be merged`,
|
bd duplicates --dry-run # Show what would be merged`,
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, _ []string) {
|
||||||
// Check daemon mode - not supported yet (merge command limitation)
|
// Check daemon mode - not supported yet (merge command limitation)
|
||||||
if daemonClient != nil {
|
if daemonClient != nil {
|
||||||
fmt.Fprintf(os.Stderr, "Error: duplicates command not yet supported in daemon mode (see bd-190)\n")
|
fmt.Fprintf(os.Stderr, "Error: duplicates command not yet supported in daemon mode (see bd-190)\n")
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// Phase 1: Get or create SQLite store for import
|
// Phase 1: Get or create SQLite store for import
|
||||||
func getOrCreateStore(ctx context.Context, dbPath string, store storage.Storage) (*sqlite.SQLiteStorage, bool, error) {
|
func getOrCreateStore(_ context.Context, dbPath string, store storage.Storage) (*sqlite.SQLiteStorage, bool, error) {
|
||||||
var sqliteStore *sqlite.SQLiteStorage
|
var sqliteStore *sqlite.SQLiteStorage
|
||||||
var needCloseStore bool
|
var needCloseStore bool
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -18,7 +18,7 @@ var initCmd = &cobra.Command{
|
|||||||
Short: "Initialize bd in the current directory",
|
Short: "Initialize bd in the current directory",
|
||||||
Long: `Initialize bd in the current directory by creating a .beads/ directory
|
Long: `Initialize bd in the current directory by creating a .beads/ directory
|
||||||
and database file. Optionally specify a custom issue prefix.`,
|
and database file. Optionally specify a custom issue prefix.`,
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, _ []string) {
|
||||||
prefix, _ := cmd.Flags().GetString("prefix")
|
prefix, _ := cmd.Flags().GetString("prefix")
|
||||||
quiet, _ := cmd.Flags().GetBool("quiet")
|
quiet, _ := cmd.Flags().GetBool("quiet")
|
||||||
|
|
||||||
|
|||||||
+3
-3
@@ -84,9 +84,9 @@ func (h *listTestHelper) assertEqual(expected, actual interface{}, field string)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *listTestHelper) assertAtMost(count, max int, desc string) {
|
func (h *listTestHelper) assertAtMost(count, maxCount int, desc string) {
|
||||||
if count > max {
|
if count > maxCount {
|
||||||
h.t.Errorf("Expected at most %d %s, got %d", max, desc, count)
|
h.t.Errorf("Expected at most %d %s, got %d", maxCount, desc, count)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-2
@@ -216,9 +216,8 @@ func performMerge(ctx context.Context, targetID string, sourceIDs []string) (*me
|
|||||||
// Ignore if dependency already exists
|
// Ignore if dependency already exists
|
||||||
if !strings.Contains(err.Error(), "UNIQUE constraint failed") {
|
if !strings.Contains(err.Error(), "UNIQUE constraint failed") {
|
||||||
return nil, fmt.Errorf("failed to add dependency %s -> %s: %w", issueID, targetID, err)
|
return nil, fmt.Errorf("failed to add dependency %s -> %s: %w", issueID, targetID, err)
|
||||||
} else {
|
|
||||||
result.depsSkipped++
|
|
||||||
}
|
}
|
||||||
|
result.depsSkipped++
|
||||||
} else {
|
} else {
|
||||||
result.depsAdded++
|
result.depsAdded++
|
||||||
}
|
}
|
||||||
|
|||||||
+7
-6
@@ -282,13 +282,14 @@ func releaseStaleIssues(staleIssues []*StaleIssueInfo) (int, error) {
|
|||||||
func formatDuration(d time.Duration) string {
|
func formatDuration(d time.Duration) string {
|
||||||
if d < time.Minute {
|
if d < time.Minute {
|
||||||
return fmt.Sprintf("%.0f seconds", d.Seconds())
|
return fmt.Sprintf("%.0f seconds", d.Seconds())
|
||||||
} else if d < time.Hour {
|
|
||||||
return fmt.Sprintf("%.0f minutes", d.Minutes())
|
|
||||||
} else if d < 24*time.Hour {
|
|
||||||
return fmt.Sprintf("%.1f hours", d.Hours())
|
|
||||||
} else {
|
|
||||||
return fmt.Sprintf("%.1f days", d.Hours()/24)
|
|
||||||
}
|
}
|
||||||
|
if d < time.Hour {
|
||||||
|
return fmt.Sprintf("%.0f minutes", d.Minutes())
|
||||||
|
}
|
||||||
|
if d < 24*time.Hour {
|
||||||
|
return fmt.Sprintf("%.1f hours", d.Hours())
|
||||||
|
}
|
||||||
|
return fmt.Sprintf("%.1f days", d.Hours()/24)
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
|||||||
+1
-1
@@ -29,7 +29,7 @@ var syncCmd = &cobra.Command{
|
|||||||
This command wraps the entire git-based sync workflow for multi-device use.
|
This command wraps the entire git-based sync workflow for multi-device use.
|
||||||
|
|
||||||
Use --flush-only to just export pending changes to JSONL (useful for pre-commit hooks).`,
|
Use --flush-only to just export pending changes to JSONL (useful for pre-commit hooks).`,
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, _ []string) {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
|
|
||||||
message, _ := cmd.Flags().GetString("message")
|
message, _ := cmd.Flags().GetString("message")
|
||||||
|
|||||||
@@ -225,9 +225,9 @@ func calculateLatencyStats(samples []time.Duration) LatencyStats {
|
|||||||
|
|
||||||
n := len(sorted)
|
n := len(sorted)
|
||||||
// Calculate percentiles with defensive clamping
|
// Calculate percentiles with defensive clamping
|
||||||
p50Idx := min(n-1, n*50/100)
|
p50Idx := minInt(n-1, n*50/100)
|
||||||
p95Idx := min(n-1, n*95/100)
|
p95Idx := minInt(n-1, n*95/100)
|
||||||
p99Idx := min(n-1, n*99/100)
|
p99Idx := minInt(n-1, n*99/100)
|
||||||
|
|
||||||
// Calculate average
|
// Calculate average
|
||||||
var sum time.Duration
|
var sum time.Duration
|
||||||
@@ -251,7 +251,7 @@ func calculateLatencyStats(samples []time.Duration) LatencyStats {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func min(a, b int) int {
|
func minInt(a, b int) int {
|
||||||
if a < b {
|
if a < b {
|
||||||
return a
|
return a
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -140,7 +140,7 @@ func NewServer(socketPath string, store storage.Storage) *Server {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Start starts the RPC server and listens for connections
|
// Start starts the RPC server and listens for connections
|
||||||
func (s *Server) Start(ctx context.Context) error {
|
func (s *Server) Start(_ context.Context) error {
|
||||||
if err := s.ensureSocketDir(); err != nil {
|
if err := s.ensureSocketDir(); err != nil {
|
||||||
return fmt.Errorf("failed to ensure socket directory: %w", err)
|
return fmt.Errorf("failed to ensure socket directory: %w", err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -294,7 +294,7 @@ func deduplicateIncomingIssues(issues []*types.Issue) []*types.Issue {
|
|||||||
// If an error occurs partway through, some issues may be created without their references
|
// If an error occurs partway through, some issues may be created without their references
|
||||||
// being updated. This is a known limitation that requires storage layer refactoring to fix.
|
// being updated. This is a known limitation that requires storage layer refactoring to fix.
|
||||||
// See issue bd-25 for transaction support.
|
// See issue bd-25 for transaction support.
|
||||||
func RemapCollisions(ctx context.Context, s *SQLiteStorage, collisions []*CollisionDetail, allIssues []*types.Issue) (map[string]string, error) {
|
func RemapCollisions(ctx context.Context, s *SQLiteStorage, collisions []*CollisionDetail, _ []*types.Issue) (map[string]string, error) {
|
||||||
idMapping := make(map[string]string)
|
idMapping := make(map[string]string)
|
||||||
|
|
||||||
// Sync counters before remapping to avoid ID collisions
|
// Sync counters before remapping to avoid ID collisions
|
||||||
|
|||||||
@@ -1524,7 +1524,7 @@ func (s *SQLiteStorage) resolveDeleteSet(ctx context.Context, tx *sql.Tx, ids []
|
|||||||
return ids, s.trackOrphanedIssues(ctx, tx, ids, idSet, result)
|
return ids, s.trackOrphanedIssues(ctx, tx, ids, idSet, result)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *SQLiteStorage) expandWithDependents(ctx context.Context, tx *sql.Tx, ids []string, idSet map[string]bool) ([]string, error) {
|
func (s *SQLiteStorage) expandWithDependents(ctx context.Context, tx *sql.Tx, ids []string, _ map[string]bool) ([]string, error) {
|
||||||
allToDelete, err := s.findAllDependentsRecursive(ctx, tx, ids)
|
allToDelete, err := s.findAllDependentsRecursive(ctx, tx, ids)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("failed to find dependents: %w", err)
|
return nil, fmt.Errorf("failed to find dependents: %w", err)
|
||||||
|
|||||||
Reference in New Issue
Block a user