Coverage for src\llm_code_lens\utils.py: 0%
28 statements
« prev ^ index » next coverage.py v7.7.0, created at 2025-05-25 12:07 +0300
« prev ^ index » next coverage.py v7.7.0, created at 2025-05-25 12:07 +0300
1"""
2LLM Code Lens - Utility Functions
3Shared utility functions used across multiple modules.
4"""
6from typing import Dict, List, Set, Optional
8def estimate_todo_priority(text: str) -> str:
9 """
10 Estimate TODO priority based on content.
12 Args:
13 text: The text of the TODO comment
15 Returns:
16 Priority level: 'high', 'medium', or 'low'
17 """
18 text = text.lower()
19 if any(word in text for word in ['urgent', 'critical', 'fixme', 'bug', 'memory leak', 'security']):
20 return 'high'
21 if any(word in text for word in ['important', 'needed', 'should']):
22 return 'medium'
23 return 'low'
25def is_potential_entry_point(file_path: str, analysis: dict) -> bool:
26 """
27 Identify if a file is a potential entry point.
29 Args:
30 file_path: Path to the file
31 analysis: Analysis data for the file
33 Returns:
34 bool: True if the file is likely an entry point
35 """
36 from pathlib import Path
38 filename = Path(file_path).name
39 if filename in {'main.py', 'app.py', 'cli.py', 'server.py', 'index.js', 'server.js'}:
40 return True
42 # Check for main-like functions
43 for func in analysis.get('functions', []):
44 if func.get('name') in {'main', 'run', 'start', 'cli', 'execute'}:
45 return True
47 return False
49def is_core_file(analysis: dict) -> bool:
50 """
51 Identify if a file is likely a core component.
53 Args:
54 analysis: Analysis data for the file
56 Returns:
57 bool: True if the file is likely a core component
58 """
59 # Check function count
60 if len(analysis.get('functions', [])) > 5:
61 return True
63 # Check class count
64 if len(analysis.get('classes', [])) > 2:
65 return True
67 # Check function complexity
68 complex_funcs = sum(1 for f in analysis.get('functions', [])
69 if (f.get('complexity', 0) > 5 or
70 f.get('loc', 0) > 50 or
71 len(f.get('args', [])) > 3))
72 if complex_funcs >= 1:
73 return True
75 # Check file complexity
76 if analysis.get('metrics', {}).get('complexity', 0) > 20:
77 return True
79 return False