Search for TODO/FIXME/HACK comments.
()
| 288 | |
| 289 | |
| 290 | def search_todos() -> List[str]: |
| 291 | """Search for TODO/FIXME/HACK comments.""" |
| 292 | todos = [] |
| 293 | patterns = ["TODO", "FIXME", "HACK"] |
| 294 | exclude_dirs_str = "|".join(EXCLUDE_DIRS | {"test", "tests", "__tests__", "spec", "__mocks__", "fixtures"}) |
| 295 | |
| 296 | try: |
| 297 | for root, dirs, files in os.walk(Path.cwd()): |
| 298 | # Remove excluded directories from dirs to prevent os.walk from descending |
| 299 | dirs[:] = [d for d in dirs if d not in EXCLUDE_DIRS and d not in {"test", "tests", "__tests__", "spec", "__mocks__", "fixtures"}] |
| 300 | |
| 301 | for file in files: |
| 302 | # Check file extension |
| 303 | ext = Path(file).suffix.lstrip('.') |
| 304 | if ext not in SOURCE_EXTS: |
| 305 | continue |
| 306 | |
| 307 | filepath = Path(root) / file |
| 308 | try: |
| 309 | with open(filepath, 'r', encoding='utf-8', errors='replace') as f: |
| 310 | for line_num, line in enumerate(f, 1): |
| 311 | for pattern in patterns: |
| 312 | if pattern in line: |
| 313 | rel_path = filepath.relative_to(Path.cwd()) |
| 314 | todos.append(f"{rel_path}:{line_num}: {line.strip()}") |
| 315 | except Exception: |
| 316 | pass |
| 317 | except Exception: |
| 318 | pass |
| 319 | |
| 320 | return todos[:TODO_LIMIT] |
| 321 | |
| 322 | |
| 323 | def get_git_commits() -> List[str]: |