Commit 237718adb834

Vincent Demeester <vincent@sbr.pm>
2026-02-19 16:37:18
fix(review-tool): drop unclassified items on folder filter
Items without project/repository/directory metadata were passing through exclude filters. Now any active folder filter drops items that have no folder metadata, since they cannot be meaningfully classified.
1 parent e8223db
Changed files (2)
tools
review-tool
tools/review-tool/internal/filter/filter.go
@@ -55,17 +55,19 @@ func (f *Filter) FilterItems(items []activity.ActivityItem) []activity.ActivityI
 func (f *Filter) Match(item activity.ActivityItem) bool {
 	folders := itemFolders(item)
 
+	// Items with no folder metadata are dropped when any folder filter is active.
+	// They can't be classified, so they shouldn't slip through.
+	if len(folders) == 0 {
+		return false
+	}
+
 	// Exclude check: if any folder matches an exclude pattern, reject
 	if len(f.ExcludeFolders) > 0 && matchesAny(folders, f.ExcludeFolders) {
 		return false
 	}
 
 	// Include check: at least one folder must match an include pattern
-	// Items with no folder metadata pass include filters (they can't be classified)
 	if len(f.IncludeFolders) > 0 {
-		if len(folders) == 0 {
-			return false
-		}
 		return matchesAny(folders, f.IncludeFolders)
 	}
 
tools/review-tool/internal/filter/filter_test.go
@@ -49,7 +49,7 @@ func TestFilter_ExcludeFolder(t *testing.T) {
 		{"excludes home project", item(map[string]string{"project": "~/src/home (homelab)"}), false},
 		{"excludes home dir", item(map[string]string{"directory": "~/src/home"}), false},
 		{"keeps tektoncd", item(map[string]string{"project": "tektoncd/pipeline"}), true},
-		{"no metadata passes", item(map[string]string{}), true},
+		{"no metadata excluded", item(map[string]string{}), false},
 	}
 
 	for _, tt := range tests {