Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions internal/campaign/edge_case_detector.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,10 @@ func (d *EdgeCaseDetector) AnalyzeFiles(ctx context.Context, paths []string, int
decisions := make([]FileDecision, 0, len(paths))

for _, path := range paths {
if strings.TrimSpace(path) == "" {
continue
}

select {
case <-ctx.Done():
logging.Campaign("Edge case analysis interrupted: %d/%d files analyzed before timeout", len(decisions), len(paths))
Expand Down Expand Up @@ -800,10 +804,6 @@ func (a *EdgeCaseAnalysis) GetPreworkTasks() []string {
// analyzeFile should aggressively verify ctx.Err() before executing heavy operations,
// potentially mid-query, to prevent leaking goroutines or excessive delay.

// TODO: Missing Edge Case - Null/Undefined/Empty: Empty string in paths slice.
// AnalyzeFiles should filter or reject `""` paths before processing them.
// detectLanguage, matchesPath, and other file utilities behavior on `""` should be explicit.

// TODO: Missing Edge Case - Null/Undefined/Empty: IntelligenceReport fields are empty.
// If an empty IntelligenceReport is passed, missing dependencies or metrics could lead
// to incorrect Action decisions.
Expand Down
9 changes: 3 additions & 6 deletions internal/campaign/edge_case_detector_gaps_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,9 @@ func TestEdgeCaseDetectorGap_EmptyPathString(t *testing.T) {
paths := []string{""}
decisions, _ := detector.AnalyzeFiles(context.Background(), paths, nil)

if len(decisions) != 1 {
t.Fatalf("Expected 1 decision, got %d", len(decisions))
}

if decisions[0].Language != "unknown" {
t.Errorf("Expected unknown language for empty path, got %s", decisions[0].Language)
// Since we fixed the bug, empty paths are filtered out.
if len(decisions) != 0 {
t.Fatalf("Expected 0 decisions for empty path, got %d", len(decisions))
}
}

Expand Down
32 changes: 32 additions & 0 deletions internal/campaign/edge_case_detector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -329,3 +329,35 @@ func TestEdgeCaseAnalysis_FileCategories(t *testing.T) {
// TODO: Missing Edge Case - Extreme Values: Max file size boundaries.
// Test determineAction with `LineCount = math.MaxInt32`.
// Expected behavior: Should cleanly suggest ActionModularize without overflow in heuristics (e.g., complexity calc).

func TestEdgeCaseDetector_AnalyzeFiles_EmptyPaths(t *testing.T) {
detector := NewEdgeCaseDetector(nil, nil)
ctx := context.Background()

// Mix of valid and empty paths
paths := []string{"valid1.go", "", " ", "valid2.go"}

decisions, err := detector.AnalyzeFiles(ctx, paths, nil)

if err != nil {
t.Fatalf("AnalyzeFiles failed: %v", err)
}

// We expect decisions only for "valid1.go" and "valid2.go"
if len(decisions) != 2 {
t.Fatalf("Expected 2 decisions for 2 valid paths, got %d", len(decisions))
}

// Verify the decisions are actually for the valid paths
pathsFound := make(map[string]bool)
for _, dec := range decisions {
pathsFound[dec.Path] = true
}

if !pathsFound["valid1.go"] {
t.Errorf("Expected decision for 'valid1.go', but not found")
}
if !pathsFound["valid2.go"] {
t.Errorf("Expected decision for 'valid2.go', but not found")
}
}