Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

8. TODO regular expression pattern and file scanning

Date: 2026-04-22

Status

Accepted

Context

Cerebro must reliably find TODO, Needs Fixing, Hack, and Placeholder comments in source code without 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 the keyword plus optional text after : or whitespace

File scanning:

  • Uses ignore::WalkBuilder to respect .gitignore
  • Skips binary and non-source extensions such as png, jpg, pdf, and zip

From highest to lowest, the sort priority is Needs Fixing, TODO, Hack, 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.