fix(codelensignore): honor !-negation patterns for files in ignored directories — closes #120#126
Merged
Merged
Conversation
…irectories — closes #120 Bug: when a directory matched a .codelensignore pattern (e.g. 'src/'), scan.py called dirs.clear() to prune the entire subtree. This meant !-negation patterns targeting files inside the ignored directory (e.g. '!src/utils.py') were never evaluated — the files were already skipped at the directory level. Fix: when a directory matches a .codelensignore pattern, check whether any pattern in the merged 3-tier list starts with '!'. If so, keep recursing so per-file is_ignored() checks can honor the negation. If there are no negation patterns, prune as before (preserves the node_modules/ performance optimization). Verified: scan on clean_app with 'src/' + '!src/utils.py' now reports python: 3 (config/settings.py + main.py + src/utils.py) instead of 2. Per-file is_ignored() correctly returns False for src/utils.py.
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



What
Fixes RED TEAM issue #120:
.codelensignorenegation pattern (!) was silently ignored — files that should be re-included via!patternwere not appearing in scan results.Root cause
When a directory matched a
.codelensignorepattern (e.g.src/),scan.pycalleddirs.clear()to prune the entire subtree. This meant!-negation patterns targeting files inside the ignored directory (e.g.!src/utils.py) were never evaluated — the files were already skipped at the directory level before per-fileis_ignored()checks ran.Fix
When a directory matches a
.codelensignorepattern, check whether any pattern in the merged 3-tier list starts with!. If so, keep recursing so per-fileis_ignored()checks can honor the negation. If there are no negation patterns, prune as before (preserves thenode_modules/performance optimization).Verification
Reproduced the bug from #120 and verified the fix:
Per-file
is_ignored()correctly returnsFalseforsrc/utils.py(negation honored).Test plan
Risk
Low. The performance optimization (pruning
node_modules/subtrees) is preserved when there are no negation patterns. Only workspaces that use!-negation will recurse into ignored directories, and that's the correct behavior — the user explicitly asked to re-include specific files.