From f968cb31d939f0339bd07e3da91ebb1978173d5d Mon Sep 17 00:00:00 2001 From: Alex Dunmow Date: Thu, 18 Jun 2026 16:53:18 +0800 Subject: [PATCH] fix: skip gitignored .worktrees/ dirs in repo scans Directory walkers pruned .git/vendor/node_modules but not .worktrees/, so a repo scan descended into nested git worktrees (e.g. an orchestrator worktree under cms/.worktrees/). Their Go/TS files surfaced as false positives in the standalone-plugin import check and noise in the any-usage warnings. Add ".worktrees" to the skip set across the implicated and common walkers: proto RBAC proto-scan, standalone-plugin imports, frontend extras, go-lint, sqlc-uuid, presets.json, and plugin segmentation. Co-Authored-By: Claude Opus 4.8 (1M context) --- frontend_extra.go | 8 ++++---- lint.go | 2 +- plugin_imports.go | 2 +- presets.go | 2 +- proto_rbac.go | 8 ++++---- segmentation.go | 4 ++-- sqlc_uuid.go | 2 +- 7 files changed, 14 insertions(+), 14 deletions(-) diff --git a/frontend_extra.go b/frontend_extra.go index 2a81f5d..5fcde0b 100644 --- a/frontend_extra.go +++ b/frontend_extra.go @@ -42,7 +42,7 @@ func checkTabState(webSrcDir string) []tabStateViolation { if !strings.HasSuffix(path, ".tsx") { return nil } - if strings.Contains(path, "node_modules") || strings.Contains(path, "/dist/") { + if strings.Contains(path, "node_modules") || strings.Contains(path, "/dist/") || strings.Contains(path, "/.worktrees/") { return nil } @@ -109,7 +109,7 @@ func checkESLintDisableNextLine(root string) []eslintDirectiveViolation { if ext != ".ts" && ext != ".tsx" && ext != ".js" && ext != ".jsx" { return nil } - if strings.Contains(path, "node_modules") || strings.Contains(path, "/dist/") { + if strings.Contains(path, "node_modules") || strings.Contains(path, "/dist/") || strings.Contains(path, "/.worktrees/") { return nil } @@ -169,7 +169,7 @@ func checkBareImports(webSrcDir string) []bareImportViolation { if ext != ".ts" && ext != ".tsx" { return nil } - if strings.Contains(path, "node_modules") || strings.Contains(path, "/dist/") { + if strings.Contains(path, "node_modules") || strings.Contains(path, "/dist/") || strings.Contains(path, "/.worktrees/") { return nil } @@ -220,7 +220,7 @@ func checkLockfiles(repoRoot string) []lockfileViolation { if err != nil || info.IsDir() { return nil } - if strings.Contains(path, "node_modules") { + if strings.Contains(path, "node_modules") || strings.Contains(path, "/.worktrees/") { return filepath.SkipDir } base := filepath.Base(path) diff --git a/lint.go b/lint.go index 1d5a8ad..9a6631c 100644 --- a/lint.go +++ b/lint.go @@ -235,7 +235,7 @@ func dirContainsTypeScript(root string) bool { } if info.IsDir() { switch info.Name() { - case "node_modules", "dist", "build", ".git": + case "node_modules", "dist", "build", ".git", ".worktrees": return filepath.SkipDir } return nil diff --git a/plugin_imports.go b/plugin_imports.go index 0411740..8187f68 100644 --- a/plugin_imports.go +++ b/plugin_imports.go @@ -59,7 +59,7 @@ func checkStandalonePluginImports(root string) []pluginImportViolation { } if info.IsDir() { switch info.Name() { - case ".git", "vendor", "node_modules": + case ".git", ".worktrees", "vendor", "node_modules": return filepath.SkipDir } return nil diff --git a/presets.go b/presets.go index 1526052..5d2bb6f 100644 --- a/presets.go +++ b/presets.go @@ -96,7 +96,7 @@ func findPresetsFiles(root string) []string { if err != nil || info.IsDir() { if info != nil && info.IsDir() { switch info.Name() { - case ".git", "vendor", "node_modules", "web", "dist": + case ".git", ".worktrees", "vendor", "node_modules", "web", "dist": return filepath.SkipDir } } diff --git a/proto_rbac.go b/proto_rbac.go index 5480b18..3e09343 100644 --- a/proto_rbac.go +++ b/proto_rbac.go @@ -46,7 +46,7 @@ func checkEnvReads(root string) []envViolation { return nil } // Skip vendor - if strings.Contains(path, "/vendor/") { + if strings.Contains(path, "/vendor/") || strings.Contains(path, "/.worktrees/") { return nil } @@ -170,7 +170,7 @@ func extractBufProcedures(root string, allowedPackagePrefixes ...string) ([]stri return err } if info.IsDir() { - if info.Name() == "vendor" || info.Name() == ".git" { + if info.Name() == "vendor" || info.Name() == ".git" || info.Name() == ".worktrees" { return filepath.SkipDir } return nil @@ -499,7 +499,7 @@ func extractPluginRoleMethods(root string) (map[string]string, error) { } if info.IsDir() { switch info.Name() { - case ".git", "vendor", "node_modules": + case ".git", ".worktrees", "vendor", "node_modules": return filepath.SkipDir } return nil @@ -578,7 +578,7 @@ func extractConnectProceduresRecursive(root string, allowedPackagePrefixes ...st } if info.IsDir() { switch info.Name() { - case ".git", "vendor", "node_modules": + case ".git", ".worktrees", "vendor", "node_modules": return filepath.SkipDir } return nil diff --git a/segmentation.go b/segmentation.go index d55329e..2f27479 100644 --- a/segmentation.go +++ b/segmentation.go @@ -101,7 +101,7 @@ func checkNoGoImports(pluginRoot, pluginName string, forbidden []string) []segme // Skip non-Go, test files, vendor, .git, web directory if info.IsDir() { base := filepath.Base(path) - if base == ".git" || base == "vendor" || base == "web" || base == "node_modules" { + if base == ".git" || base == ".worktrees" || base == "vendor" || base == "web" || base == "node_modules" { return filepath.SkipDir } return nil @@ -155,7 +155,7 @@ func checkNoFrontendImports(pluginRoot, pluginName string, forbidden []string) [ } if info.IsDir() { base := filepath.Base(path) - if base == "node_modules" || base == "dist" || base == ".git" { + if base == "node_modules" || base == "dist" || base == ".git" || base == ".worktrees" { return filepath.SkipDir } return nil diff --git a/sqlc_uuid.go b/sqlc_uuid.go index 95805a0..c1b220b 100644 --- a/sqlc_uuid.go +++ b/sqlc_uuid.go @@ -82,7 +82,7 @@ func findSQLCConfigFiles(root string, includeRoot bool) []string { } if info.IsDir() { switch info.Name() { - case ".git", "vendor", "node_modules", "dist": + case ".git", ".worktrees", "vendor", "node_modules", "dist": return filepath.SkipDir } return nil