Description
The shouldScan() method in diagnostics.ts implements a naive glob matcher that only handles **/ prefix patterns using string inclusion checks. This means complex exclude patterns like **/test_*, **/target/**, or **/fixtures/*.rs do not work correctly in all cases.
Current State
private shouldScan(filePath: string): boolean {
const patterns = this.config.exclude.split(',');
const relativePath = path.relative(workspaceFolder, filePath);
return !patterns.some(pattern => {
const glob = pattern.trim();
if (glob.startsWith('**/')) {
return relativePath.includes(glob.slice(3));
}
return false;
});
}
Problems:
relativePath.includes('test_*') treats * as a literal character, not a glob wildcard
- Patterns without
**/ prefix are silently ignored (return false)
- Cannot exclude specific file extensions or directories properly
Expected Behavior
Use a proper glob matching library (or VS Code's built-in glob support) for exclude pattern evaluation:
- Replace the naive implementation with
minimatch (already compatible with VS Code patterns)
- Support all standard glob patterns:
*, **, ?, {a,b}, etc.
- Validate patterns at configuration time and warn about invalid patterns
- Consider using
vscode.RelativePattern or vscode.GlobPattern for consistency with VS Code's own pattern matching
Implementation Notes
minimatch is already a transitive dependency through VS Code types — add it as an explicit devDependency
- Or use
picomatch for a lighter alternative
- Add unit tests for pattern matching with common exclude scenarios
- Cache compiled patterns for performance
Acceptance Criteria
Complexity
Trivial — replace a simple function with a well-tested library, add tests.
Points
100
Description
The
shouldScan()method indiagnostics.tsimplements a naive glob matcher that only handles**/prefix patterns using string inclusion checks. This means complex exclude patterns like**/test_*,**/target/**, or**/fixtures/*.rsdo not work correctly in all cases.Current State
Problems:
relativePath.includes('test_*')treats*as a literal character, not a glob wildcard**/prefix are silently ignored (returnfalse)Expected Behavior
Use a proper glob matching library (or VS Code's built-in glob support) for exclude pattern evaluation:
minimatch(already compatible with VS Code patterns)*,**,?,{a,b}, etc.vscode.RelativePatternorvscode.GlobPatternfor consistency with VS Code's own pattern matchingImplementation Notes
minimatchis already a transitive dependency through VS Code types — add it as an explicit devDependencypicomatchfor a lighter alternativeAcceptance Criteria
**/test_*excludes files liketest_utils.rsandsrc/test_helper.rs**/target/**excludes all files in target directories**/fixtures/*.rsexcludes Rust files in fixtures but not other file typesComplexity
Trivial — replace a simple function with a well-tested library, add tests.
Points
100