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 regex pattern and file scanning

Date: 2026-04-22

Status

Accepted

Context

We need to reliably find TODO/FIXME/HACK/XXX comments in source code while avoiding false positives.

Decision

Regex pattern:

(?i)\b(TODO|FIXME|HACK|XXX)\b[\s:]*(.*)$

Features:

  • Case-insensitive matching ((?i))
  • Word boundary anchors (\b)
  • Captures keyword + optional text after : or whitespace

File scanning:

  • Uses ignore::WalkBuilder to respect .gitignore
  • Skips binary/non-source extensions (png, jpg, pdf, zip, etc.)

Sorting priority: FIXME > TODO > HACK > XXX

Consequences

Pros

  • Case-insensitive catches todo:, TODO:, Todo:
  • Respects gitignore automatically
  • Skips common false positives (minified JS, images)

Cons

  • Won’t catch multi-line comments
  • Won’t catch TODO in strings without keyword prefix

Notes

See collectors/todos.rs for implementation.