@@ -11,6 +11,10 @@ import {
1111 isIgnored ,
1212 applyIgnore ,
1313 loadIgnore ,
14+ DEFAULT_IGNORE_DIRS ,
15+ DEFAULT_IGNORE_FILES ,
16+ DEFAULT_IGNORE_PATTERNS ,
17+ buildScannerIgnoreGlobs ,
1418} from '../src/ignore.js' ;
1519import { runAnalysis } from '../src/index.js' ;
1620
@@ -112,3 +116,84 @@ test('pathologically wildcard-heavy patterns are refused (fail-open)', () => {
112116 // Fail-open: a refused pattern suppresses nothing.
113117 assert . equal ( isIgnored ( 'a' . repeat ( 101 ) , compileIgnorePatterns ( [ '*a' . repeat ( 101 ) ] ) ) , false ) ;
114118} ) ;
119+
120+ test ( 'DEFAULT_IGNORE_DIRS covers vendored deps, build output, and generated caches' , ( ) => {
121+ for ( const d of [
122+ 'node_modules' ,
123+ '.git' ,
124+ 'dist' ,
125+ 'build' ,
126+ 'vendor' ,
127+ 'target' ,
128+ '__pycache__' ,
129+ '.dart_tool' , // Flutter/Dart cache (the dominant external-tool noise source)
130+ '.gradle' , // Gradle/Android cache
131+ '.supabase' , // Supabase CLI local runtime state
132+ 'csreview-reports' ,
133+ '.csreview' ,
134+ ] ) {
135+ assert . ok ( DEFAULT_IGNORE_DIRS . includes ( d ) , `expected DEFAULT_IGNORE_DIRS to include ${ d } ` ) ;
136+ }
137+ } ) ;
138+
139+ test ( 'DEFAULT_IGNORE_PATTERNS are gitignore-syntax and scope external-tool findings to first-party source' , ( ) => {
140+ const compiled = compileIgnorePatterns ( DEFAULT_IGNORE_PATTERNS ) ;
141+ // the real-world noise from CaiuPixOld: a Chrome profile under .dart_tool
142+ assert . ok ( isIgnored ( 'flutter/apps/operator/.dart_tool/chrome-device/Default/Preferences' , compiled ) ) ;
143+ assert . ok ( isIgnored ( 'supabase-stuff/.supabase/postgres/data/x' , compiled ) ) ;
144+ assert . ok ( isIgnored ( 'android/app/.gradle/cache/x' , compiled ) ) ;
145+ assert . ok ( isIgnored ( 'a/node_modules/pkg/index.js' , compiled ) ) ;
146+ assert . ok ( isIgnored ( 'packages/web/dist/bundle.min.js' , compiled ) ) ;
147+ // root-level cache dirs (no parent component) must also match — guards against
148+ // an anchoring regression in the matcher (Codex M1)
149+ assert . ok ( isIgnored ( '.supabase/local/x' , compiled ) ) ;
150+ assert . ok ( isIgnored ( '.dart_tool/package_config.json' , compiled ) ) ;
151+ assert . ok ( isIgnored ( 'node_modules/pkg/index.js' , compiled ) ) ;
152+ // first-party source is never suppressed by the defaults
153+ assert . ok ( ! isIgnored ( 'src/index.js' , compiled ) ) ;
154+ assert . ok ( ! isIgnored ( 'lib/feature.dart' , compiled ) ) ;
155+ // the dot-dir default must NOT swallow the real `supabase/` source tree
156+ assert . ok ( ! isIgnored ( 'supabase/migrations/0001_init.sql' , compiled ) ) ;
157+ // every default file glob is present in the compiled pattern set (export is intentional, Codex N1)
158+ for ( const f of DEFAULT_IGNORE_FILES ) assert . ok ( DEFAULT_IGNORE_PATTERNS . includes ( f ) , `missing default file ${ f } ` ) ;
159+ } ) ;
160+
161+ test ( 'buildScannerIgnoreGlobs retains every legacy scanner exclusion and adds the new caches' , ( ) => {
162+ const globs = buildScannerIgnoreGlobs ( ) ;
163+ for ( const legacy of [
164+ '**/node_modules/**' ,
165+ '**/.git/**' ,
166+ '**/dist/**' ,
167+ '**/build/**' ,
168+ '**/.next/**' ,
169+ '**/.nuxt/**' ,
170+ '**/coverage/**' ,
171+ '**/__pycache__/**' ,
172+ '**/.venv/**' ,
173+ '**/venv/**' ,
174+ '**/.tox/**' ,
175+ '**/.mypy_cache/**' ,
176+ '**/vendor/**' ,
177+ '**/target/**' ,
178+ '**/bin/**' ,
179+ '**/obj/**' ,
180+ '**/*.min.js' ,
181+ '**/*.min.css' ,
182+ '**/.trae/**' ,
183+ '**/.vscode/**' ,
184+ '**/.idea/**' ,
185+ '**/security-report.html' ,
186+ '**/security-findings.md' ,
187+ '**/csreview-report.html' ,
188+ '**/csreview-report.md' ,
189+ '**/*_security-report.html' ,
190+ '**/*_security-findings.md' ,
191+ '**/csreview-reports/**' ,
192+ '**/.csreview/**' ,
193+ ] ) {
194+ assert . ok ( globs . includes ( legacy ) , `regression: lost legacy scanner glob ${ legacy } ` ) ;
195+ }
196+ assert . ok ( globs . includes ( '**/.dart_tool/**' ) ) ;
197+ assert . ok ( globs . includes ( '**/.gradle/**' ) ) ;
198+ assert . ok ( globs . includes ( '**/.supabase/**' ) ) ;
199+ } ) ;
0 commit comments