Remove dead code: splitLines loop, unused methods (gt-2g130)
- polecat.go: Remove unreachable first loop in splitLines (was using filepath.SplitList incorrectly) - townlog/logger.go: Remove unused Event.JSON() method and json import - lock/lock.go: Remove unused ErrStaleLock error variable - refinery/manager.go: Remove unused getTestCommand() method Note: witness.StatePaused is actually used by cmd/witness.go, not dead code. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
+2
-13
@@ -1205,20 +1205,9 @@ func runPolecatRecycle(cmd *cobra.Command, args []string) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// splitLines splits a string into non-empty lines.
|
// splitLines splits a string into lines.
|
||||||
func splitLines(s string) []string {
|
func splitLines(s string) []string {
|
||||||
var lines []string
|
return strings.Split(s, "\n")
|
||||||
for _, line := range filepath.SplitList(s) {
|
|
||||||
if line != "" {
|
|
||||||
lines = append(lines, line)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// filepath.SplitList doesn't work for newlines, use strings.Split instead
|
|
||||||
lines = nil
|
|
||||||
for _, line := range strings.Split(s, "\n") {
|
|
||||||
lines = append(lines, line)
|
|
||||||
}
|
|
||||||
return lines
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func runPolecatNuke(cmd *cobra.Command, args []string) error {
|
func runPolecatNuke(cmd *cobra.Command, args []string) error {
|
||||||
|
|||||||
@@ -22,10 +22,9 @@ import (
|
|||||||
|
|
||||||
// Common errors
|
// Common errors
|
||||||
var (
|
var (
|
||||||
ErrLocked = errors.New("worker is locked by another agent")
|
ErrLocked = errors.New("worker is locked by another agent")
|
||||||
ErrNotLocked = errors.New("worker is not locked")
|
ErrNotLocked = errors.New("worker is not locked")
|
||||||
ErrStaleLock = errors.New("stale lock detected")
|
ErrInvalidLock = errors.New("invalid lock file")
|
||||||
ErrInvalidLock = errors.New("invalid lock file")
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// LockInfo contains information about who holds a lock.
|
// LockInfo contains information about who holds a lock.
|
||||||
|
|||||||
@@ -519,20 +519,6 @@ func (m *Manager) completeMR(mr *MergeRequest, closeReason CloseReason, errMsg s
|
|||||||
_ = m.saveState(ref) // non-fatal: state file update
|
_ = m.saveState(ref) // non-fatal: state file update
|
||||||
}
|
}
|
||||||
|
|
||||||
// getTestCommand returns the test command if configured.
|
|
||||||
func (m *Manager) getTestCommand() string {
|
|
||||||
// Check settings/config.json for test_command
|
|
||||||
settingsPath := filepath.Join(m.rig.Path, "settings", "config.json")
|
|
||||||
settings, err := config.LoadRigSettings(settingsPath)
|
|
||||||
if err != nil {
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
if settings.MergeQueue != nil && settings.MergeQueue.TestCommand != "" {
|
|
||||||
return settings.MergeQueue.TestCommand
|
|
||||||
}
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
|
|
||||||
// runTests executes the test command.
|
// runTests executes the test command.
|
||||||
func (m *Manager) runTests(testCmd string) error {
|
func (m *Manager) runTests(testCmd string) error {
|
||||||
parts := strings.Fields(testCmd)
|
parts := strings.Fields(testCmd)
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
package townlog
|
package townlog
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
@@ -272,12 +271,6 @@ func splitLines(s string) []string {
|
|||||||
return lines
|
return lines
|
||||||
}
|
}
|
||||||
|
|
||||||
// LogEventJSON writes an event in JSON format for machine parsing.
|
|
||||||
// Returns the JSON representation.
|
|
||||||
func (e Event) JSON() ([]byte, error) {
|
|
||||||
return json.Marshal(e)
|
|
||||||
}
|
|
||||||
|
|
||||||
// TailEvents returns the last n events from the log.
|
// TailEvents returns the last n events from the log.
|
||||||
func TailEvents(townRoot string, n int) ([]Event, error) {
|
func TailEvents(townRoot string, n int) ([]Event, error) {
|
||||||
events, err := ReadEvents(townRoot)
|
events, err := ReadEvents(townRoot)
|
||||||
|
|||||||
Reference in New Issue
Block a user