Coverage for src\llm_code_lens\processors\insights.py: 86%
21 statements
« prev ^ index » next coverage.py v7.6.1, created at 2025-01-12 10:23 +0200
« prev ^ index » next coverage.py v7.6.1, created at 2025-01-12 10:23 +0200
1from typing import Dict, List, Set
2from pathlib import Path
4def generate_insights(analysis: Dict[str, dict]) -> List[str]:
5 """Generate insights with improved handling."""
6 insights = []
8 # Basic project stats
9 total_files = len(analysis) if isinstance(analysis, dict) else 0
10 if total_files == 1:
11 insights.append("Found 1 analyzable file")
12 elif total_files > 0:
13 insights.append(f"Found {total_files} analyzable files")
15 # Track metrics
16 todo_count = 0
17 memory_leaks = 0
18 for file_analysis in analysis.values():
19 if isinstance(file_analysis, dict):
20 todos = file_analysis.get('todos', [])
21 todo_count += len(todos)
22 # Check for memory leak TODOs
23 memory_leaks += sum(1 for todo in todos
24 if 'memory leak' in todo.get('text', '').lower())
26 if todo_count > 0:
27 insights.append(f"Found {todo_count} TODOs across {total_files} files")
28 if memory_leaks > 0:
29 insights.append(f"Found {memory_leaks} potential memory leak issues")
31 return insights