Description
The utils/data_loader.py contains dead code - an unused cache mechanism that is defined but never actually implemented or used anywhere in the codebase. This adds confusion and increases maintenance overhead.
Affected File
utils/data_loader.py (lines 51-57)
Problem
The module defines a cache variable and a function to clear it:
# Cache for loaded projects
_projects_cache = None
def clear_cache():
"""Reset the in-memory project cache."""
global _projects_cache
_projects_cache = None
However:
_projects_cache is never used in any function - load_all_projects() and find_project_by_id() always read directly from the JSON file
clear_cache() is never called anywhere in the codebase
- There's no cache implementation - the variable is defined but no logic populates or uses it
Evidence
Search the codebase for usage:
load_all_projects() (lines 11-14): Opens and reads file every time
find_project_by_id() (lines 17-25): Calls load_all_projects() directly each time
- No calls to
clear_cache() exist anywhere
Impact
- Confusion: Developers might think caching is implemented and try to use it
- Maintenance: Dead code must be maintained, tested, and documented unnecessarily
- Code bloat: Adds 7 unnecessary lines to the codebase
- False promises: The comment "Cache for loaded projects" suggests functionality that doesn't exist
Expected Behavior
Either:
- Option A: Remove the dead code entirely if caching isn't needed
- Option B: Implement actual caching if performance optimization is the goal
Given that the project works fine without caching (10 projects in JSON), Option A is recommended.
Suggested Fix
Remove lines 51-57 from utils/data_loader.py:
# REMOVE THIS DEAD CODE:
# Cache for loaded projects
_projects_cache = None
def clear_cache():
"""Reset the in-memory project cache."""
global _projects_cache
_projects_cache = None
Alternatively, if caching is desired for future performance improvement, implement it properly:
_projects_cache = None
def load_all_projects():
"""Read and return the full list of projects from the JSON file."""
global _projects_cache
if _projects_cache is None:
with open(DATA_FILE, "r", encoding="utf-8") as f:
_projects_cache = json.load(f)
return _projects_cache
def clear_cache():
"""Reset the in-memory project cache."""
global _projects_cache
_projects_cache = None
Description
The
utils/data_loader.pycontains dead code - an unused cache mechanism that is defined but never actually implemented or used anywhere in the codebase. This adds confusion and increases maintenance overhead.Affected File
utils/data_loader.py(lines 51-57)Problem
The module defines a cache variable and a function to clear it:
However:
_projects_cacheis never used in any function -load_all_projects()andfind_project_by_id()always read directly from the JSON fileclear_cache()is never called anywhere in the codebaseEvidence
Search the codebase for usage:
load_all_projects()(lines 11-14): Opens and reads file every timefind_project_by_id()(lines 17-25): Callsload_all_projects()directly each timeclear_cache()exist anywhereImpact
Expected Behavior
Either:
Given that the project works fine without caching (10 projects in JSON), Option A is recommended.
Suggested Fix
Remove lines 51-57 from
utils/data_loader.py:Alternatively, if caching is desired for future performance improvement, implement it properly: