refactor: Remove duplicate isLoopback function from hostagent

The isLoopback function in internal/hostagent/agent.go was unused in
production code - it was a duplicate of the same function in
internal/hostmetrics/collector.go which is actively used.

Removed the dead code along with its associated tests to reduce
maintenance burden and improve code clarity.
This commit is contained in:
rcourtman 2025-12-02 16:52:55 +00:00
parent c108cba8bb
commit 185e7098bd
2 changed files with 0 additions and 71 deletions

View file

@ -325,15 +325,6 @@ func normalisePlatform(platform string) string {
}
}
func isLoopback(flags []string) bool {
for _, flag := range flags {
if strings.EqualFold(flag, "loopback") {
return true
}
}
return false
}
// collectTemperatures attempts to collect temperature data from the local system.
// Returns an empty Sensors struct if collection fails (best-effort).
func (a *Agent) collectTemperatures(ctx context.Context) agentshost.Sensors {

View file

@ -72,65 +72,3 @@ func TestNormalisePlatform(t *testing.T) {
}
}
func TestIsLoopback(t *testing.T) {
tests := []struct {
name string
flags []string
expected bool
}{
{
name: "loopback lowercase",
flags: []string{"up", "loopback"},
expected: true,
},
{
name: "LOOPBACK uppercase",
flags: []string{"up", "LOOPBACK"},
expected: true,
},
{
name: "Loopback mixed case",
flags: []string{"up", "Loopback"},
expected: true,
},
{
name: "loopback only flag",
flags: []string{"loopback"},
expected: true,
},
{
name: "no loopback flag",
flags: []string{"up", "broadcast", "running"},
expected: false,
},
{
name: "empty flags",
flags: []string{},
expected: false,
},
{
name: "nil flags",
flags: nil,
expected: false,
},
{
name: "loopback first",
flags: []string{"loopback", "up"},
expected: true,
},
{
name: "loopback in middle",
flags: []string{"up", "loopback", "running"},
expected: true,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
result := isLoopback(tt.flags)
if result != tt.expected {
t.Errorf("isLoopback(%v) = %v, want %v", tt.flags, result, tt.expected)
}
})
}
}