Overview
TheFileScanner class is responsible for discovering source code files in a directory while respecting ignore rules and exclusions.
Constructor
rootDir(string): The root directory to scan
Properties
rootDir
string
supportedExtensions
Set<string>
Default values:
ignoreDirs
Set<string>
Default values:
gitignorePatterns
.gitignore.
Type: string[]
Methods
scanFiles()
Scans the directory and returns an array of file paths.Private Methods
_loadGitignore()
Loads and parses the.gitignore file.
- Reads
.gitignorefrom root directory - Filters out comments (lines starting with
#) - Filters out empty lines
- Returns array of patterns
_shouldIgnorePath(filePath)
Determines if a path should be ignored.filePath(string): Path to check
true if should be ignored, false otherwise
Checks:
- Built-in ignore directories
- Gitignore patterns
_scanDirectory(dir)
Recursively scans a directory.dir(string): Directory to scan
Usage Examples
Basic Scanning
Custom Extensions
Custom Ignore Directories
Filtering Results
Scan Multiple Directories
Count Files by Extension
Integration Examples
With AnalysisEngine
Selective Scanning
Progress Tracking
Gitignore Support
The FileScanner automatically respects.gitignore patterns:
Error Handling
FileScanner silently ignores inaccessible directories and continues scanning. This prevents permission errors from stopping the entire scan.
Performance Considerations
Large Repositories
Large Repositories
For very large codebases (> 10,000 files):
Efficient Ignore Patterns
Efficient Ignore Patterns
Add commonly large directories to ignoreDirs:
Extension Filtering
Extension Filtering
Remove unused extensions to reduce file count:
API Summary
Next Steps
AnalysisEngine
Learn how to analyze files
PatternScanner
Explore pattern detection
Usage Guide
See practical usage examples
Supported Languages
Check supported file types

