Skip to content

fix(rules): bug-todo matches the word "todo" in identifiers, module names and prose (22 of 22 hits were false positives) #681

Closed

Description

@ajianaz

Problem

bug-todo reports "TODO/FIXME/HACK/XXX comment found. Consider resolving before merge." for any occurrence of the word todo, case-insensitively, including in code and ordinary prose. Projects that have a to-do feature (task lists, todo_write, a todo module) get a flood of info-level false positives.

Reproduction (cora 0.19.0, cora scan --no-llm)

src/a.rs:

pub mod todo;                       // line 1  -> reported (false positive: a module name)
fn f() { let todo_state = 1; let _ = todo_state; }   // line 2 -> not reported
/// the todo list is per session    // line 3  -> reported (false positive: prose)
fn g() {}
// TODO(me): real marker             // line 5  -> reported (correct)

Result: 3 findings; only line 5 is a real marker.

On a real 133-file Rust workspace with a task-list feature: 22 bug-todo hits, 22 false positives (e.g. let todo_state = tole_core::todo::TodoState::new();, .register(Box::new(tole_core::todo::TodoWriteTool::new(...))), pub mod todo;, doc comments about "todo state is per-session", a CHANGELOG line). Zero real TODO markers were present.

Proposal

Match only deliberate markers:

  • case-sensitive TODO, FIXME, HACK, XXX as whole words,
  • only inside a comment (//, ///, /* */, #, --, <!-- -->, %), not in code or string literals,
  • optionally followed by (owner) or :.
    Keep the message and severity. A rules_engine option (or bug-todo params) for extra marker words would be a nice follow-up.

Done when

The repro reports only line 5; a regression test covers identifier, module name, prose in a comment ("the todo list"), lower-case todo, and the real markers TODO:, TODO(x):, FIXME, HACK, XXX.

Related: #663 (test-code awareness for built-in rules).

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugpriority:mediumscope:core

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions