Skip to content

fix(prefilter): use token-boundary matching for test and migration framework detection - #68

Open
Adityakk9031 wants to merge 1 commit into
Corgea:mainfrom
Adityakk9031:fix/prefilter-token-boundary-test-migration
Open

fix(prefilter): use token-boundary matching for test and migration framework detection#68
Adityakk9031 wants to merge 1 commit into
Corgea:mainfrom
Adityakk9031:fix/prefilter-token-boundary-test-migration

Conversation

@Adityakk9031

Copy link
Copy Markdown
Contributor

Summary

  • Replaces unbounded substring matching in has_test_patterns and has_migration_patterns with token-boundary aware matching matches_token_or_module.
  • Prevents false-positive test file exclusions on legitimate production files that import modules containing substrings of test words (such as \�ttestation, \contest, \latest, \ astest, \user_migration).
  • Adds regression unit test cases in \ ests/unit/prefilter_should_scan_tests.rs.

@juangaitanv
juangaitanv self-requested a review August 17, 2026 08:32
Comment thread src/scanner/prefilter.rs
];

test_patterns.iter().any(|pattern| imports_text.contains(pattern))
test_patterns.iter().any(|pattern| Self::matches_token_or_module(imports_text, pattern))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

vitest, Go testing, and testify no longer match the test patterns, so their imports are scanned. could we retain explicit patterns for these framework roots while preserving the boundary fix?

Comment thread src/scanner/prefilter.rs
Comment on lines -249 to -251
"migration",
"migrations",
"migrate",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

from django.db import migrations no longer matches a migration pattern, so those files are scanned in general mode. could we retain generic migration indicators while treating _ and digits as identifier characters?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants