Loading page...Загружаем страницу...正在加载页面...
AtlasRepo

Case Study: A Free Model Wrote a C++ TODO Expiry Checker

说明与用途

案例研究:构建一个 C++17 工具来检查过期的 TODO 注释。作者使用了 MonkeyCode AI 模型,经历了三轮迭代:从编译通过但逻辑错误的代码,到能够处理字符串字面量和无效日期的解决方案。关键教训:编译成功并不保证行为正确。

问题

TODO comments in codebases accumulate without dates or owners, becoming technical debt. There is a need for a tool to scan C++ repositories, extract ISO dates from TODO/FIXME comments, and fail CI builds if deadlines have passed, while correctly ignoring string literals and handling invalid dates.

结果

After three iterations, a C++17 tool was successfully created that accurately identifies expired TODOs while ignoring false positives in string literals and handling invalid dates. The key lesson was that compilation success does not guarantee logical correctness, and AI models may default to newer language standards (C++20) unless constrained.

工作流

  • Define the problem: Scan .cpp/.hpp/.h/.cc files for TODO/FIXME with ISO dates.
  • Create a test fixture: 23 source files with 47 tokens including expired, active, undated, string-literal, block-comment, and malformed date cases.
  • Round 1: Generate code with AI. Result: Compiled but failed fixture (false positives in strings, accepted invalid dates).
  • Round 2: Fix string literal issue. Result: Failed compilation due to C++20 dependencies in C++17 project.
  • Round 3: Implement C++17-compatible date logic (days_from_civil) and a state machine for parsing. Result: Passed fixture.
  • Integrate tool into CI to fail builds on expired TODOs.

证据

The first draft compiled on the first try. That was the only thing it did correctly.

来源

The second draft... used std::chrono::year_month_day... which are C++20 types. The project toolchain is C++17.

来源

  • 记录日期: 2026-09-05T18:29:50.121Z