8. TODO regular expression pattern and file scanning
Date: 2026-04-22
Status
Accepted
Context
Cerebro must find TODO, Needs Fixing, Hack, and Placeholder comments reliably in source code while avoiding false positives.
Decision
Regex pattern:
(?i)\b(TODO|FIXME|HACK|XXX)\b[\s:]*(.*)$
Features:
- Case-insensitive matching using the
(?i)flag - Word boundary anchors using
\b - Captures keyword + optional text after
:or whitespace
File scanning:
- Uses
ignore::WalkBuilderto respect.gitignore - Skips binary/non-source extensions (png, jpg, pdf, zip, etc.)
Sorting priority from highest to lowest covers Needs Fixing, then TODO, then Hack, then Placeholder.
Consequences
Pros
- Case-insensitive catches
todo:,TODO:,Todo: - Respects gitignore automatically
- Skips common false positives, such as minified JS and images
Cons
- Won’t catch multi-line comments
- Won’t catch TODO in strings without keyword prefix
Notes
See collectors/todos.rs for implementation.